Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

44 Objective Type Questions Introduction to Computer Programming | CSC 3405, Study notes of Computer Science

Material Type: Notes; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/16/2009

koofers-user-9tl-1
koofers-user-9tl-1 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 11
Recursion
 Multiple ChoiceMultiple Choice
1) A recursive method is one that:
(a) Returns a value
(b) Initializes a set of variables
(c) Returns no value
(d) Invokes itself
2) All recursive methods must have a/an:
(a) starting case
(b) intermediate case
(c) stopping case
(d) none of the above
3) Pick the best answer
(a) Recursive methods may include a recursive call
(b) Recursive methods may not use iteration
(c) Recursive methods must include a recursive call
(d) none of the above
4) Recursion is:
(a) the ability of a program to call itself
(b) the ability of a method to call itself
1
pf3
pf4
pf5

Partial preview of the text

Download 44 Objective Type Questions Introduction to Computer Programming | CSC 3405 and more Study notes Computer Science in PDF only on Docsity!

Chapter 11

Recursion

 Multiple Choice

  1. A recursive method is one that: (a) Returns a value (b) Initializes a set of variables (c) Returns no value (d) Invokes itself
  2. All recursive methods must have a/an: (a) starting case (b) intermediate case (c) stopping case (d) none of the above
  3. Pick the best answer (a) Recursive methods may include a recursive call (b) Recursive methods may not use iteration (c) Recursive methods must include a recursive call (d) none of the above
  4. Recursion is: (a) the ability of a program to call itself (b) the ability of a method to call itself 1

(c) the ability of a method to call smaller methods (d) the ability of a method to implement factorials

  1. Regarding recursion, if a base case is never reached the result is: (a) infinite recursion (b) iteration (c) termination (d) all of the above
  2. Infinite recursion: (a) will happen when there is no base case (b) will not happen when there is a base case (c) will not happen if we use subproblems (d) none of the above
  3. The underlying data structure used by the computer during recursion is a: (a) queue (b) linked list (c) tree (d) stack
  4. The stack is a ________________ data structure. (a) first in – first out (b) last in – last out (c) last in – first out

14) What is the value returned when the integer 5 is the argument to the factorial method?

  • (a)
  • (b)
  • (c)
  • (d)
  • (a)

(b) 50 (c) 100 (d) 120

  1. When defining recursive valued methods you should: (a) Ensure there is no infinite recursion. (b) Ensure each stopping case returns the correct value for that case. (c) Ensure that the final value returned by the method is the correct value. (d) All of the above
  2. When defining recursive void methods you should: (a) Ensure there is no infinite recursion. (b) Ensure that each stopping case performs the correct action for that case. (c) Ensure that if all recursive calls perform their actions correctly, then the entire case performs correctly. (d) All of the above
  3. The order of magnitude of the binary search algorithm is: (a) linear (b) exponential (c) logarithmic (d) quadratic  True/False
  4. A method definition that includes a call to itself is said to be recursive.
  5. When a recursive call is encountered, computation is temporarily suspended; all of the information needed to continue the computation is saved and the recursive call is evaluated.
  6. A base case must include a recursive call.
  7. To keep track of recursion most computer systems us a structure called a queue.
  8. A stack is a last-in/first-out memory structure.
  9. Activation records are used to implement recursion.
  10. A recursively written method will usually run slower and use more storage than an equivalent iterative version.
  11. A recursive method must never return a value.
  12. Binary search is a divide and conquer algorithm.
  13. The binary search algorithm is extremely slow compared to an algorithm that simply tries all array elements in order.
  14. The binary search algorithm has worst-case running time that is logarithmic.  Short Answer/Essay Write a recursive method to compute the power of xn^ for non-negative n.