Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Notas de lectura

Recursion in Data Structure

Puntuación
-
Vendido
-
Páginas
10
Subido en
28-01-2023
Escrito en
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.

Institución
Grado

Vista previa del contenido

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

Escuela, estudio y materia

Grado

Información del documento

Subido en
28 de enero de 2023
Número de páginas
10
Escrito en
2022/2023
Tipo
NOTAS DE LECTURA
Profesor(es)
Lecturer arnold
Contiene
Todas las clases

Temas

$8.49
Accede al documento completo:

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Conoce al vendedor
Seller avatar
Mnyazi

Conoce al vendedor

Seller avatar
Mnyazi Freelancer
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
-
Miembro desde
4 año
Número de seguidores
0
Documentos
119
Última venta
-

0.0

0 reseñas

5
0
4
0
3
0
2
0
1
0

Documentos populares

Recientemente visto por ti

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes