Recursion
Recursion
POLYTECHNIC
Kopergaon, Ahmednagar - 423603
A
PROJECT REPORT
ON
”RECURSION”
CERTIFICATE
This is to certify that project report entitled
”RECURSION”
Submitted by
Under our supervision and guidance for partial fulfillment of the requirement for
Diploma in Computer Technology affiliated to
Maharashtra State Board of Technical Education, Mumbai
For academic year
2021 - 2022
2
ACKNOWLEDGEMENT
First and the foremost we, express my deep sense of gratitude, sin-
cere thanks and deep sense of appre- ciation to Project Guide Mr. V.A.
Parjane, Department of Computer Technology,Sanjivani K.B.P. Poly-
technic, Kopargaon. Your availability at any time throughout the year,
valuable guidance, opinion, view, comments, critics, encouragement, and
support tremendously boosted this project work.
Last but not the least, we should say thanks from our bottom of heart
to my Family and Friends for their never ending love, help, and support
in so many ways through all this time.
3
INDEX
4
1. Introduction to Recursion :-
5
2. What is Recursion in C? :-
The function call itself is known as recursive function and the re-
cursion is the process where the function called itself. The recursive
function also referred as self-called function. Whenever a function
called from itself, then there will be an infinite loop. To break this
infinite loop every recursive function must check the terminating con-
dition and then decide whether to call the function again or not. The
example below will show the way of writing this type of function in
C programming.
6
Systax :-
7
3. Advantages and Disadvantages :-
ADVANTAGES :-
1. Recursive processor are easiest to write.
2. Recursive processor are easiest to understand .
3. It is easier to give recursive solution to real life complex prob-
lem rather iterative solutions are tougher or complex . for example:-
Tower of hanoi , Tree Traversal etc.
4. For a recursive function, you only need to define the base case and
recursive case, so the code is simpler and shorter than an iterative
code.
5. Some problems are inherently recursive, such as Graph and Tree
Traversal.
6. The code may be easier to write.
7. To solve such problems which are naturally recursive such as tower
of Hanoi.
DISADVANTAGES :-
1. Recursive procedures are relatively slower than it’s equivalent it-
erative solution.
2. Recursive solutions are occupy more memory as compare to the
equivalent iterative solution.
3. A recursive program has greater space requirements than an iter-
ative program as each function call will remain in the stack until the
base case is reached.
4. It also has greater time requirements because each time the func-
tion is called, the stack grows and the final answer is returned when
the stack is popped completely
5. Recursive functions are generally slower than non-recursive func-
tion
8
4. Program 1 :-
9
10
11
5. Program 2 :-
12
13
6. Conclusion :-
14
7. References :-
15