Don’t worry, unlock all articles / blogs on PrepInsta by just simply logging in on our website
Type atleast 3 characters
Popular Searches
Trending Pages
Notifications Mark All Read
No New notification
InfyTQ Menu9>
PREPINSTA PRIME
Get Hiring Updates right in your inbox from PrepInsta
Question 1
int solution( int N ) { if ( base case ) { return something } else { divide problem into pieces return something calculated from the solution to each piece }
int solution( int N ) { if ( base case ) { return something easily computed } else { return solution(N) } }
int solution( int N ) { divide problem into pieces return something calculated from the solution to each piece }
int solution( int N ) { divide problem into pieces if ( base case ) { return something easily computed } else { return something calculated from the solution to each piece } }
Start
Question 2
1 public static int factorial(int n) 2 { 3 if (n == 0) 4 return 1; 5 else return n * factorial(n-1); 6 }
1
3
4
5
Question 3
public String starString(int n){ if (n == 0) { return "*";} else{ return starString(n - 1) + starString(n - 1);}}
6
Question 4
square(1) = 1 square(N) = square(N-1) + 2N -1
square(3) = square(2) + square(1)
square(3) = square(2) - 2*3 +1
square(3) = square(2) + 2*3 -1
square(3) = square(3) + 2*3 -1
Question 5
(i) static view, and (ii) dynamic view.
(i) recursive view, and (ii) iterative view
(i) math view, and (ii) programming view
(i) code view, and (ii) translation view
Question 6
1 public static int multiplyEvens(int n) 2 { 3 if (n == 1) { 4 return 2; 5 } else { 6 return 2 * n * multiplyEvens(n - 1); 7 } 8 }
2
Question 7
An infinite loop occurs
System stops the program after some time
After 1000000 calls it will be automatically stopped.
None of the mentioned
Question 8
java.lang
java.util
java.io
java.system
Question 9
24
30
120
720
Question 10
Runtime Error
Please login to report