You are on page 1of 18

A

MICRO PROJECT REPORT


ON

“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

1. KHARAT NIKITA 2114640039 CO-3-I


2. DHUMAL VARSHA 2114640048 CO-3-I
3. GAYAKHE AKANSHA 2114640071 CO-3-I

Under the Guidance of

PROF. ANAWADE A.

In partial fulfillment of requirement for the award of


Diploma In computer engineering.

MSBTE, Mumbai.

Academic Year: 2022-23


S.S.M. ADSUL POLYTECHNIC COLLEGE,CHAS, AHMEDNAGAR-414 005(M.S)
S.S.M. ADSUL POLYTECHNIC COLLEGE,
CHAS,AHMEDNAGAR- 414005(M.S)

CERTIFICATE
This is to certify that the micro project report entitled

RECURSION IN ‘C’
Submitted by,
Name of student Enrollment No Program

1. KHARAT NIKITA 2114640039 CO-3-I


2. DHUMAL VARSHA 2114640048 CO-3-I
3. GAYAKHE AKANSHA 2114640071 CO-3-I

Of semester I institute, Sau. Sundarabai Manik Adsul Polytechnic, Chas, Ahmednagar


(code: 1464) has completed the micro project satisfactorily in course (22317) for the Academic
year 2022-23 as prescribed in the MSBTE curriculum.

Place: Ahmednagar Date: ………………………….

Prof. Anawade. A.V Prof. Hole.P.P Prof .Gadakh.R.S.


(Micro Project guide) (Head of Dept.) (Principal)

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. KHARAT NIKITA PRAKASH


2. DHUMAL VARSHA SOPAN
3. GAYAKHE AKANSH ANIL
PART A-PLAN
1.0 INTRODUCTION
we must be aware of the data structures in programming, here we will discuss an interesting
topic in programming that is recursion in data structure. Computers, mobiles, cars, airplanes
do you know what they have in common? Coding! Every technology that we rely on today is
powered by coding or programming.
Nowadays many schools are even giving basic coding knowledge in primary classes. A lot of
programming languages incorporate an immense collection of built-in data structures for
organizing code and data. Computer systems use binary codes and all the software that is in
there runs the system using 0’s and 1’s only.
Do you know? There can be infinite combinations of these two digits as a result new software
can be written all the time. We will give you in-depth guidance for everything possible related
to recursion in data structure. Even if you are a complete beginner in programming don’t
worry, we will discuss every topic from scratch.
Note: With recursion in Data Structures you must also know about the graph in data
structure

2.0What is Data Structure?


The data structure term implies by itself that organizing the data in memory. You will find
numerous ways of arranging the information in the memory like the array present in C
language. The array is a set of memory components in which info is saved sequentially, i.e.,
one right after another. Put simply, we can state that the array stores the components in a
consistent fashion.
This kind of organization of details is accomplished with the assistance of an array of data
structures. Additionally, there are alternative approaches to managing the data in memory.
Let us look at the various sorts of data structures.
The data structure just isn’t any programming language as C, Java, C++, etc. It’s a set of
algorithms that we can apply in almost any programming language to structure the
information in the memory.
To structure the data in memory,’ n’ number of algorithms had been suggested, and the
majority of these algorithms are referred to as Abstract data types. These abstract data types
are a set of rules.
3.0 What is Recursion in Data Structure :-
In general terms recursion means the process to define a problem or the solution for a
problem in a much simpler way compared to the original version. It is a problem-solving
programming technique that has a remarkable and unique characteristic.
In recursion in data structure, a method or a function has the capability to decode an issue.
In the process of recursion, a problem is resolved by transforming it into small variations of
itself. In this procedure, the function can call itself either directly or indirectly. Based on the
differences in call recursion in data structure can be categorized into different categories.
You will get to know about these categories later in the blog.
Recursion in data structure is additionally an adequate programming technique. A recursive
subroutine is described as one that directly or indirectly calls itself. Calling a subroutine
specifically indicates that the characterization of the subroutine already has the call
statement of calling the subroutine that has been defined.
Moreover, the indirect calling of the subroutine takes place whenever a subroutine calls
another subroutine, which in turn calls the first subroutine. Recursion in data structure can
use several lines of code to refer to an elaborate job.

4.0 ACTION PLAN


Sr. Planned Start Planned Finish Name of Responsible
No. Details of Activity Date Date Team Members

1 Finalization of Topic 08/09/2022 20/09/2022 All Team members

2 Project definition and planning 10/09/2022 22/09/2022 Kharat Nikita

3 Requirement Gathering 15/09/2022 23/09/2022 Dhumal Varsha

4 Design Modeling 22/09/2022 01/11/2022 Gayakhe Akansha

5 Implementation of Code 25/09/2022 06/11/2022 ALL TEAM MEMBERS

6 Integration and Testing 05/11/2022 07/11/2022 Kharat Nikita

7 Launch Application 10/11/2022 20/11/2022 Dhumal Varsha

8 Documentation 18/11/2022 20/11/2022 Gayakhe Akansha


5.0 RESOURCES REQUIRED
Sr.
No. Name Of Resource/material Specifications Quantity Remarks

1 Computer System I5 4th gen 500 GB HDD 4GB RAM 1

2 Turbo C Version 3.0,64 bit 1

PART B-(OUTCOMES AFTER EXECUTION)

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.

2.0 COURSE OUTCOMES INTEGRATED

a) Develop code to understand c programming language approach.


b) Understand concept of structure and functions
c) Understand logical concepts.
3.0 A] ACTUAL PROCEDURE FOLLOWED

• 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.

3.0 B] SOURCE CODE

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

Runtime Test Cases


Enter size of the list:8
Printing the list:
7 6 1 3 1 7 2 4
The largest number in the list is: 7
C Program for Tower of Hanoi
3.0 C] Problem Description
Write a C program to solve the Tower of Hanoi Problem.

What is Tower of Hanoi?


Tower of Hanoi is a mathematical game or a puzzle which consists of 3 rods or pegs and n disks
of various diameters. Tower of Hanoi 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.

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.

Rules of Tower of Hanoi Puzzle:


• Only one disk may be moved at a time.
• Each move consists of taking the upper disk from one of the stacks and placing it on
top of another stack or on an empty rod.
• No disk may be placed on top of a disk that is smaller than it.
Example:
Suppose no of disks are 4 and the starting rod is ‘A’, the auxiliary rod is ‘B’ and the ending rod is
‘C’.
In each step first we move the top most node of peg ‘A’ to auxiliary peg ‘B’ and then finally move
to ‘C’ which is the desired peg.
Initially:
All disks are stack on peg ‘A’ with order of their size being Disk3 < Disk2 < Disk1
Peg A Peg B Peg C

Disc 3
Disc 2
Disc 1
Moving Disc 3 To Peg C:

Peg A Peg B Peg C

Disc 2
Disc 1 Disc 3
Moving Disc 2 To Peg B:

Peg A Peg B Peg C

Disc 1 Disc 2 Disc 3


Moving Disc 3 To Peg B:
Take Data Structure I Practice Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Peg A Peg B Peg C

Disc 3
Disc 1 Disc 2
Moving Disc 1 To Peg C:

Peg A Peg B Peg C

Disc 3
Disc 2 Disc 1
Moving Disc 3 To Peg B:

Peg A Peg B Peg C

Disc 3 Disc 2 Disc 1


Moving Disc 2 To Peg C:

Peg A Peg B Peg C

Disc 3 Disc 2
Disc 1
Moving Disc 3 To Peg C:

Peg A Peg B 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.

Tower of Hanoi Algorithm:


Step 1: Start the program.
Step 2: Input number of disks.
Step 3: Declare a function which takes the number of disks, starting disk, auxiliary disk and final
disk as argument and recursively calls itself twice.
Step 4: Call the function.
Step 5: End the Program.

3.1 Program/Source Code


Here is the source code of the C program for tower of hanoi. The C Program is successfully
compiled and run on a Linux system. The program output is also shown below.
1. /*
2. * Tower of Hanoi Program in C 3. */
4.
5. #include <stdio.h>
6.
7. void towers(int, char, char, char);
8.
9. int main()
10. {
11. int num;
12.
13. printf("Enter the number of disks : ");
14.
15. scanf("%d", &num);
16.
17. printf("The sequence of moves involved in the Tower of
Hanoi are :\n");
18.
19. towers(num, 'A', 'C', 'B');
20.
21. return 0;
22. }
23. void towers(int num, char frompeg, char topeg, char
auxpeg)
24. {
25. // Base Condition if no of disks are
26.
27. if (num == 1)
28.
29. {
30.

printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg);

31. return;
32.
33. } 34.

35. // Recursively calling function twice


36.
37. towers(num - 1, frompeg, auxpeg, topeg);
38.
39. printf("\n Move disk %d from peg %c to peg %c", num,
frompeg, topeg);
40.
41. towers(num - 1, auxpeg, topeg, frompeg);
42.
43. }

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.

Time Complexity: O(2n)


In each function call, we are calling the function twice so time complexity of tower of hanoi
program is O(2n ).
Space Complexity: O(n)
Space of the recursive stack is of order n, so space complexity of tower of hanoi program is O(n).
Program Output
In this case, the user enters “3” as the number of discs as input to solve the Tower of Hanoi
puzzle.

Enter the number of disks : 3

The sequence of moves involved in the Tower of Hanoi are :

Move disk 1 from peg A to peg C


Move disk 2 from peg A to peg B
Move disk 1 from peg C to peg B
Move disk 3 from peg A to peg C
Move disk 1 from peg B to peg A
Move disk 2 from peg B to peg C
Move disk 1 from peg A to peg C

4.0 ACTUAL RESOURCES USED

Sr. Name of Specifications Quantity Remarks


No. resources/material
1 Computer system I5 4th gen 500 GB HDD 4GB RAM 1

2 Turbo C Version 3.0,64 bit 1


5.0 SKILL DEVELOPED / LEARNING OUT OF THIS MICRO-PROJECT

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

Title of the Project: RECURSION IN ‘C’


COs addressed by the Micro Project:
A: Use computer system and its peripherals.
B: Prepare business document using word processing tool.
Major learning outcomes achieved by students by doing the Project:
(a)Practical outcomes:
1. Implement a ‘c’ program to sort an array using stack.
2. Create, edit and save document.
3. Document Page Layout.
(b)Unit outcomes in Cognitive domain:
2a. write steps to evaluate the given expression using the stack.
2b. Editing document, Formatting paragraphs, spacing & align.
2c. Inserting elements to word documents, Changing layout of a document.
(c)Outcomes in Affective Domain----------------------------------------------------------------------
-----------------------------------------------------------------------------------------
Comments/Suggestion about team work/leadership/inter-personal communication
(if any)

Marks out of 6 for Marks out of 4 for


Roll Total out
No. Student Name performance in group performance in oral/
of 10
activity (D5 Col. 8) presentation (D5 Col.9)
1 KHARAT NIKITA PRAKASH
2 DHUNAL VARSHA SOPAM
3 GAYAKHE AKANSHA ANIL

(Name & Signature of Faculty)

You might also like