Recursive function in programming exercises


Question 1:

a) What do you mean by recursion?

b) What benefit is there in its use?

c) What drawbacks are there in its use?

Question 2: The factorial of a positive number can be calculated by using the formula:

n! = 1 x 2 x 3 x………x n

Though, the function factorial can as well be defined as a recursive function in programming exercises.

Write down the major part of the program that comprises the given:

a) The function prototype
b) A positive integer variable n
c) An output statement to display n
d) An input statement to permit a user to enter a number (which is stored in variable n)
e) The other output statement which computes and displays the factorial of the number.
f)  Write down the function by using recursion.

Question 3:

a) Describe why a linked list is called a dynamic data structure?
b) What are the three most significant benefits of using linked list over arrays?
c) State one drawbacks of using linked list in structured programs.

Question 4: A stack is as well a dynamic data structure that can be implemented in its simplest manner by making use of arrays.

Declare a structure comprising:

a) An integer array to hold the elements of the stack

b) An integer to point out the position of the current stack top in the array.

Now write the “pop” operation to eliminate the top element from the stack.
Write the “push” operation to add an element to the stack.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Recursive function in programming exercises
Reference No:- TGS06287

Expected delivery within 24 Hours