100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

DSA Recursion Questions with Solved Answers

Rating
-
Sold
-
Pages
2
Grade
A+
Uploaded on
29-08-2024
Written in
2024/2025

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

Institution
DSA
Course
DSA








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
DSA
Course
DSA

Document information

Uploaded on
August 29, 2024
Number of pages
2
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

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

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Dreamer252 NBursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
477
Member since
2 year
Number of followers
293
Documents
21305
Last sold
1 week ago

4.0

115 reviews

5
60
4
22
3
18
2
2
1
13

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions