Question: For the following Example write the recursive algorithm Find an element in Array of n elements: To count # of elements in an array Factorial

  1. For the following Example write the recursive algorithm
    1. Find an element in Array of n elements:
    1. To count # of elements in an array
    2. Factorial of integer n
    1. For the following recursive program identify the base and the recursive steps

int fact ( int n )

{

if ( n == 0 ) return 1;

return n * fact(n-1);

}

Base Case is:

Recursive step is :

    1. Explain how the factorial of 4 works
    1. The recursive algorithm is ----------------- select the correct answer

Linear logarithmic exponential Non

    1. The recursive algorithm time complexity is ( select the correct answer)
      1. O(n)
      2. O(n2)
      3. O(n-1) O(n)
      4. O(2n)
    2. The recursive algorithm of factorial has time complexity -----
    1. The recursive algorithm of Fibonacci has time complexity -----
    1. Determine the Possible Problems Infinite Loop of the following programs and how to fix this problem
    1. int bad ( int n ) {

If(n==0) return 1;

return bad(n-1); }

  1. int bad ( int n ) {

return bad(n-1); }

 For the following Example write the recursive algorithm Find an element

    1. consider the Example Towers of Hanoi, write the steps to solve this problem in recursive approach, the problem is described as following:
      1. Move stack of disks between pegs
      2. Can only move top disk in stack
      3. Only allowed to place disk on top of larger disk
    1. List the advantage of Non recursive algorithms:
    1. List the advantage of recursive algorithms:
    2. List the disadvantage of recursive algorithms:

3RD WEG X V

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!