Geschrieben von Student*innen, die bestanden haben Sofort verfügbar nach Zahlung Online lesen oder als PDF Falsches Dokument? Kostenlos tauschen 4,6 TrustPilot
logo-home
Notizen

Recursion in Data Structure

Bewertung
-
Verkauft
-
seiten
10
Hochgeladen auf
28-01-2023
geschrieben in
2022/2023

These notes are informative on the topic of recursion in data structures. They will be beneficial for students studying computer science and information technology.

Hochschule
Kurs

Inhaltsvorschau

P a g e |1




Recursion & Data Structures

Man is always seeking solutions to problems and is always also looking
for better solutions.
In computer science, there are different class of problems each requiring
different to problems solving techniques.
We have seen how we can use loops to solve some problems quite well.
Another approach to problem solutions is Recursion.


Recursion is a problem-solving technique that involves breaking a problem into
smaller instances of the same problem (also called subproblems) until we get
a small enough subproblem having a trivial solution.
We can say that recursion is “defining a problem in terms of itself” as it involves
a function calling itself with a base case to terminate the infinite loop.
Technically, recursion is a problem-solving technique where the ultimate
solution depends on solutions to smaller instances of the same problem.
The concept relys on the fact that a problem can be solved much easily and
in lesser time if it is represented in one or smaller versions.
Consider the mathematical expression y=x7
This can linearly be expressed as follows:
6
y=x.x
5
y=x.x.x .
4
y=X.x.x.x
3
y=X.X.x.x.x
2
y=X.X.X.x.x.x
1
y=X.X.X.X.x.x.x



Recursion in data structure

, P a g e |2




0
y=X.X.X.X.X.x.x.x

y=X.X.X.X.X.x.x.1

Iterative solution
Consider y=27 . Therefore X=2; the last term is Y0=1;

Let y=1;
for (int i=1;i<=7;i++){
y*=2;
}


Write the above in a method power (int x, int y)


Using Recursion to solve the above Power Problem
Recursive functions allow programmers to write efficient programs using a
minimal amount of code.
The downside is that they can cause infinite loops and other unexpected
results if not written properly.
For example, in the example above, the function is terminated if the number is 0 .

If proper cases are not included in a recursive function to stop the execution,
it will repeat forever, causing the program to crash or become unresponsive.


Therefore care must be taken when constructing a recursive algorithms.




Recursion in data structure

Schule, Studium & Fach

Kurs

Dokument Information

Hochgeladen auf
28. januar 2023
Anzahl der Seiten
10
geschrieben in
2022/2023
Typ
Notizen
Professor(en)
Lecturer arnold
Enthält
Alle klassen

Themen

$8.49
Vollständigen Zugriff auf das Dokument erhalten:

Falsches Dokument? Kostenlos tauschen Innerhalb von 14 Tagen nach dem Kauf und vor dem Herunterladen kannst du ein anderes Dokument wählen. Du kannst den Betrag einfach neu ausgeben.
Geschrieben von Student*innen, die bestanden haben
Sofort verfügbar nach Zahlung
Online lesen oder als PDF

Lerne den Verkäufer kennen
Seller avatar
Mnyazi

Lerne den Verkäufer kennen

Seller avatar
Mnyazi Freelancer
Folgen Sie müssen sich einloggen, um Studenten oder Kursen zu folgen.
Verkauft
-
Mitglied seit
4 Jahren
Anzahl der Follower
0
Dokumente
119
Zuletzt verkauft
-

0.0

0 rezensionen

5
0
4
0
3
0
2
0
1
0

Beliebte Dokumente

Kürzlich von dir angesehen.

Warum sich Studierende für Stuvia entscheiden

on Mitstudent*innen erstellt, durch Bewertungen verifiziert

Geschrieben von Student*innen, die bestanden haben und bewertet von anderen, die diese Studiendokumente verwendet haben.

Nicht zufrieden? Wähle ein anderes Dokument

Kein Problem! Du kannst direkt ein anderes Dokument wählen, das besser zu dem passt, was du suchst.

Bezahle wie du möchtest, fange sofort an zu lernen

Kein Abonnement, keine Verpflichtungen. Bezahle wie gewohnt per Kreditkarte oder Sofort und lade dein PDF-Dokument sofort herunter.

Student with book image

“Gekauft, heruntergeladen und bestanden. So einfach kann es sein.”

Alisha Student

Häufig gestellte Fragen