100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
DSA Recursion Questions with Solved Answers $12.99   Add to cart

Exam (elaborations)

DSA Recursion Questions with Solved Answers

 7 views  0 purchase
  • Course
  • DSA
  • Institution
  • DSA

Exam of 2 pages for the course DSA at DSA (DSA Recursion)

Preview 1 out of 2  pages

  • August 29, 2024
  • 2
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • DSA
  • DSA
avatar-seller
Dreamer252
DSA Recursion

1. If the user enters 10 in the triangle.java program (Listing 6.1), what is the maximum
number of "copies" of the triangle() method (actually just copies of its argument) that
exist at any one time? - answer10

2. Where are the copies of the argument, mentioned in question 1, stored?
a. in a variable in the triangle() method
b. in a field of the TriangleApp class
c. in a variable of the getString() method
d. on a stack - answerD

3. Assume the user enters 10 as in question 1. What is the value of n when the
triangle() method first returns a value other than 1? - answer2

4. Assume the same situation as in question 1. What is the value of n when the
triangle() method is about to return to main()? - answer10

5. True or false: In the triangle() method, the return values are stored on the stack. -
answerFalse

6. In the anagram.java program (Listing 6.2), at a certain depth of recursion, a version of
the doAnagram() method is working with the string "led". When this method calls a new
version of itself, what letters will the new version be working with? - answer"ed"

7. We've seen that recursion can take the place of a loop, as in the loop-oriented
orderedArray.java program (Listing 2.4) and the recursive binarySearch.java program
(Listing 6.3). Which of the following is not true?
a. Both programs divide the range repeatedly in half.
b. If the key is not found, the loop version returns because the range bounds cross, but
the recursive version occurs because it reaches the bottom recursion level.
c. If the key is found, the loop version returns from the - answerB

8. In the recFind() method in the binarySearch.java program (Listing 6.3), what takes
the place of the loop in the non-recursive version?
a. the recFind() method
b. arguments to recFind()
c. recursive calls to recFind()
d. the call from main() to recFind() - answerC

9. The binarySearch.java program is an example of the _________ approach to solving
a problem. - answerdivide-and conquer

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Dreamer252. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $12.99. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

84866 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$12.99
  • (0)
  Add to cart