Test Bank for Data Abstraction & Problem Solving with C Walls and Mirrors 6E 6th Edition

Test Bank for Data Abstraction & Problem Solving with C Walls and Mirrors 6E 6th Edition

Info icon This preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
FOR MORE OF THIS COURSE AND ANY OTHER COURSES, TEST BANKS, FINAL EXAMS, AND SOLUTION MANUALS CONTACT US AT [email protected] Chapter 2 Recursion: The Mirrors Multiple Choice Questions 1. In a recursive solution, the ______ terminates the recursive processing. a) local environment b) pivot item c) base case d) recurrence relation Answer: c. 2. A binary search uses a ______ strategy. a) divide-and-conquer b) sequential c) determine-the-pivot d) smallest-to-largest Answer: a. 3. A ______ is a mathematical formula that generates the terms in a sequence from previous terms. a) local environment b) pivot item c) base case d) recurrence relation Answer: d. 4. The factorial of n is equal to ______. 5. The base case for a recursive definition of the factorial of n is ______. a) factorial (–1) Data Abstraction & Problem Solving with C++: Walls and Mirrors, Sixth Edition, by Frank Carrano and D.J. Henry, Pearson Education-Prentice Hall, 2013 1
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
b) factorial (0) c) factorial ( n ) d) factorial ( n – 1) Answer: b. 6. What is fundamentally wrong with computing the Fibonacci sequence recursively? 7. In the box trace, each box roughly corresponds to a(n) ______. 8. In the box trace, each box contains all of the following EXCEPT ______. a) the values the function’s arguments b) the function’s local variables c) the function’s execution time d) a placeholder for the value returned by each recursive call from the current box e) the value returned by the function itself Answer: c. 9. In the box trace for a recursive function, a new box is created each time ______. 10. What happens if a recursive function never reaches a base case? 11. In a recursive method that writes a string of characters in reverse order, the base case is ______. 12. Which of the following is a precondition for a method that accepts a number n and computes the n th Fibonacci number? Data Abstraction & Problem Solving with C++: Walls and Mirrors, Sixth Edition, by Frank Carrano and D.J. Henry, Pearson Education-Prentice Hall, 2013 2
Image of page 2
a) n is a negative integer b) n is a positive integer c) n is greater than 1 d) n is an even integer Answer: b.
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern