Dsu M.P
Dsu M.P
Dsu M.P
“PROJECT ON RECURSION”
Program & Program code : CO – 3-I
Course : DATA STRUCTURE USING ‘C’ Course code : 22317
Submitted by,
Name of student Enrollment No Program
PROF. ANAWADE A.
MSBTE, Mumbai.
CERTIFICATE
This is to certify that the micro project report entitled
RECURSION IN ‘C’
Submitted by,
Name of student Enrollment No Program
External Examiner
ACKNOWLEDGEMENT
I take this opportunity to acknowledgement the constant encouragement and continuous help give
to me by my guide Prof: Anawade Aarti I convey my sincere thanks to his valuable timely
suggestion.
I would also like to thanks Principal Prof. Gadakh.R.S. And Head of department Prof: Hole.P.P I
would also like to thank teaching staff of department for achieving this goal.
I also thankful to those think which are directly or indirectly help me for completion this micro
project finally. I thank my parents without whose supports; the completion of the project would
not have been possible.
1.0 DESCRIPTION
Recursion in C Programming is technique in which function call’s itself number of
times. The function calls itself is referred as recursive function and call is
recursive call. The recursion continues until some condition is met to prevent it.
To prevent infinite recursion control statements or similar approach can be used
where one branch makes the recursive call and other doesn’t.
This program will implement a one-dimentional array defining elements in unsorted
fashion, in which we need to find largest element using Recursion method. The array
used here is of type integer.
• In the first step all the team members finalized the topic student report card.
• In the next step, Kharat Nikita defined the scope of project and planed it.
• In the next step, Dhumal Varsha did gathering of requirement.
• In the next step, Gayakhe Akansha performed design modeling task
• After that all the implementation of the code was done by all the team
members .
• The integration and testing had been carried out by Kharat Nikita
• Last but not the least the launch application completed by Dhumal Varsha
• The project was terminated by documentation section by Gayakhe Akansha
and we finally ended with completing the micro-project.
1. /*
2. * C Program to find the Biggest Number in an Array of Numbers
using
3. * Recursion 4. */
5.
6. #include <stdio.h>
7. #include <conio.h> 8.
9.
10. int large(int[], int, int);
11.
12. int main()
13. {
14.
15. int size;
16.
17. int largest;
18.
19. int list[20];
20.
21. int i;
22.
23. /* initializing variables*/
24.
25.
26. printf("Enter size of the list:");
27.
28. /* printing message here */
29.
30. printf("Printing the list:\n");
31.
32. /*………………………\n …………..for new line*/
33.
34.
35. for (i = 0; i < size ; i++)
36. {
37.
38. list[i] = rand() % size;
39.
40. printf("%d \t", list[i]);
41.
42. }
43.
44. if (size == 0)
45.
46. {
47.
48. printf("Empty list\n");
49.
50. }
51.
52. else
53. {
54.
55. largest = list[0];
56.
57. largest = large(list, size - 1, largest);
58.
59. printf("\nThe largest number in the list is: %d\n”,largest);
60.
61. }
62.
63.
64. }
65.
66. int large(int list[], int position, int largest)
67.
68. {
69.
70. if (position == 0)
71.
72. return largest;
73.
74. if (position > 0)
75. {
76.
77. if (list[position] > largest)
78. {
79.
80. largest = list[position];
81.
82. }
83.
84. return large(list, position - 1, largest);
85.
86. }
87.
88. }
OUTPUT
Problem Solution
This C program uses a recursive function to solve the Tower of Hanoi. The tower of hanoi is a
mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can
slide onto any rod. Puzzle begins with all disks stacked on one rod in decreasing order and the task
is to move all these disks on some other rod obeying the following rules.
Disc 3
Disc 2
Disc 1
Moving Disc 3 To Peg C:
Disc 2
Disc 1 Disc 3
Moving Disc 2 To Peg B:
Disc 3
Disc 1 Disc 2
Moving Disc 1 To Peg C:
Disc 3
Disc 2 Disc 1
Moving Disc 3 To Peg B:
Disc 3 Disc 2
Disc 1
Moving Disc 3 To Peg C:
Disc 3
Disc 2
Disc 1
Now this is the desired solution as all of the disks are stacked on peg ‘C’.
Following is the approach for solving the tower of hanoi problem. In this approach we recursively
call a function twice to place the disk in desired places or on desired pegs.
31. return;
32.
33. } 34.
Program Explanation
1. First input the number of disks placed on three rods.
2. Declare a function which takes 4 parameters which are: no of disks and name of initial disk,
auxiliary disk and final disk.
3. The function recursively calls itself twice to solve the problem with a base case to stop when n
is 1.
4. Call this function from main function.
After completion of the micro project, our basic concepts of MIC such as Recursion
,Branching , looping got cleared We became able to perform operations on file such as open
file, close file, read from file, and write to file and so on. We also use the control statements
like functions, if, felse, nested if else, else-if ladder, switch cases, looping statements like
while loop, do while loop.
ANNEXURE II
Evolution Sheet for the Micro Project
Academic Year: 2022-23 Name of Faculty: Prof. Anawade. A.V
Course: DSU Course Code: 22317 Semesters: 3rd