1. To recurse is to

2. To recur is to

3. Factorial is

4. factorial(0) is

5. Recursion is

6. Which of the following is not a requirement for a recursive function?

7. The function
int example(unsigned int a) { if (a==0) return 0; else return example(a+1); }
is a bad recursive function because

8. Is the following function circular?
int syracuse(int n) { if (n==1) return 0; else if (n % 2 != 0) return syracuse(n/2); else return 1 + syracuse(3*n + 1); }

9. True or False: A call stack is made up of frames.

10. True or False: During program execution, the call stack can be empty.

11. True or False: Because a recursive function calls itself, a different mechanism than the call stack is used to keep track of the function calls.

12. As a data structure, a call stack is most analogous to

13. If you were to draw out the function call tree for Fib3, how many function calls would there be in terms of big-O notation?

14. A stack is an example of a ____ data structure.

15. A queue is an example of a _____ data structure.

16. True or false: Regardless of implementation, the closed-form solution to the Fibonacci problem is always more efficient than a recursive implementation.

17. True or false: A linearly recursive function always has the recursive call at the end of the function.

18. True or false: Tail recursion is a form of linear recursion.

19. The following function is an example of what form of recursion?
int mystery(int n, int k) { if (k == 0 || n == k) return(1); else return(mystery(n-1,k) + mystery(n-1,k-1)); }

20. The following function implements what recursive function?
int mystery(char *s) { if (*s=='\0') return 0; else return(1 + mystery(s+1)); }

21. What does the following function do?
int strcmp_i(char *s, char *t) { for(; *s==*t && *s!='\0'; s,t); return(*s - *t); }

22. True or False: Merge sort is an example of a divide-and-conquer sort.

23. True or False: All recursive functions can be implemented iteratively.

24. True or False: All iterative functions can be implemented recursively.

25. What does this function do?
void mystery(int num) { if (num / 8) mystery(num / 8); putchar(num % 8 + '0'); }

26. This function is an example of what type of recursion?
int fib_r(int n) { if (n<=1) return 1; else return(fib_r(n-1) + fib_r(n-2)); }

27. Which of the following data structures could be considered a recursive data structure?

28. A recursive data structure is what?

29. fib(5) is

30. factorial(4) is

31. True or False: If a recursive function does not have a base case, the compiler will detect this and display a compiler error.

32. True or False: A recursive function must have a void return type.

33. True or False: Recursive calls are usually contained within a loop.

34. True or False: It is possible to have more than one recursive call within a function.

35. True or False: Binary search can only be written recursively.

36. Which of these statements is true about the following code?
int mystery(int n) { if (n>0) return n + mystery(n-1); return 0; }

37. Which of the following iterative functions is not equivalent to this recursive function?
int mystery(int n) { if(n > 0) return (n + mystery(n - 1)); return 0; }

38. True or False: When a recursive solution's elegance outweighs its overhead (memory, time, efficiency, etc), and when it is much less complex than an iterative solution, you would most likely choose to use the recursive solution.

39. True or False: You should always use a recursive solution rather than an iterative solution when you are sure that that recursive solution will not overflow the call stack.

40. Recursion can be an inefficient way to implement a solution because

41. True or False: Recursion happens when an algorithm does not use a loop.

42. True or False: A function can be considered recursive if it has a direct or an indirect call to itself.

43. True or False: Infinite recursion can occur when a recursive algorithm does not contain a base case.

44. True or False: Infinite recursion can occur when a recursive algorithm contains a base case.

45. True or False: Infinite recursion can occur when the base case is never reached by the algorithm.

46. A solution to a 64-disk Towers of Hanoi problem requires how many disks to be moved?

47. The following function implements which operation?
int mystery(tree_t *tree) { if (tree != NULL) { printf("%d ", tree->data); mystery(tree->left); mystery(tree->right); } }

48. The following function implements which operation?
int mystery(tree_t *tree) { if (tree != NULL) { mystery(tree->right); printf("%d ", tree->data); mystery(tree->left); } }

Popular pages: Review of Recursion