100% found this document useful (21 votes)
89 views

Free Access to Data Structures and Abstractions with Java 4th Edition Carrano Test Bank Chapter Answers

The document provides links to download test banks and solution manuals for various editions of 'Data Structures and Abstractions with Java' and other related textbooks. It includes a section on recursion with true/false questions, short answer questions, and multiple-choice questions related to recursive methods. Additionally, it contains disclaimers and information about the Project Gutenberg Literary Archive Foundation.

Uploaded by

pillastapfic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (21 votes)
89 views

Free Access to Data Structures and Abstractions with Java 4th Edition Carrano Test Bank Chapter Answers

The document provides links to download test banks and solution manuals for various editions of 'Data Structures and Abstractions with Java' and other related textbooks. It includes a section on recursion with true/false questions, short answer questions, and multiple-choice questions related to recursive methods. Additionally, it contains disclaimers and information about the Project Gutenberg Literary Archive Foundation.

Uploaded by

pillastapfic
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Visit https://testbankfan.

com to download the full version and


explore more testbank or solution manual

Data Structures and Abstractions with Java 4th


Edition Carrano Test Bank

_____ Click the link below to download _____


https://testbankfan.com/product/data-structures-and-
abstractions-with-java-4th-edition-carrano-test-bank/

Explore and download more testbank at testbankfan.com


Here are some suggested products you might be interested in.
Click the link to download

Data Structures and Abstractions with Java 4th Edition


Carrano Solutions Manual

https://testbankfan.com/product/data-structures-and-abstractions-with-
java-4th-edition-carrano-solutions-manual/

Data Structures and Abstractions with Java 5th Edition


Carrano Solutions Manual

https://testbankfan.com/product/data-structures-and-abstractions-with-
java-5th-edition-carrano-solutions-manual/

Starting Out with Java From Control Structures through


Data Structures 3rd Edition Gaddis Test Bank

https://testbankfan.com/product/starting-out-with-java-from-control-
structures-through-data-structures-3rd-edition-gaddis-test-bank/

Real Estate Finance and Investments 14th Edition


Brueggeman Test Bank

https://testbankfan.com/product/real-estate-finance-and-
investments-14th-edition-brueggeman-test-bank/
Business Law Today Standard Text and Summarized Cases 11th
Edition Miller Solutions Manual

https://testbankfan.com/product/business-law-today-standard-text-and-
summarized-cases-11th-edition-miller-solutions-manual/

Essentials of Cultural Anthropology 1st Edition Guest Test


Bank

https://testbankfan.com/product/essentials-of-cultural-
anthropology-1st-edition-guest-test-bank/

Java Foundations 3rd Edition John Lewis Test Bank

https://testbankfan.com/product/java-foundations-3rd-edition-john-
lewis-test-bank/

Anatomy and Physiology 8th Edition Patton Test Bank

https://testbankfan.com/product/anatomy-and-physiology-8th-edition-
patton-test-bank/

International Business 7th Edition Collinson Solutions


Manual

https://testbankfan.com/product/international-business-7th-edition-
collinson-solutions-manual/
Introduction to Criminology 3rd Edition Walsh Test Bank

https://testbankfan.com/product/introduction-to-criminology-3rd-
edition-walsh-test-bank/
Chapter 7 - Recursion

True/False (10)

1. The program stack stores activation records chronologically.

Answer: true

2. Recursive method calls create multiple copies of the method in memory.

Answer: false

3. A recursive method uses less memory than an iterative method.

Answer: false

4. You can use a recurrence relation to determine the performance of a recursive method.

Answer: true

5. Recursive methods do not return a value.

Answer: false

6. Activation records for recursive methods are the same as activation records for non-recursive
methods.

Answer: true

7. You should always trace a recursive method to ensure it is correct.

Answer: false

8. An iterative solution to the Towers of Hanoi problem moves fewer disks than the recursive
solution.

Answer: false

9. Converting a tail-recursive method to an iterative method is usually a straightforward process.

Answer: true

10. You can replace recursion with iteration by simulating the program stack.

Answer: true
Short Answer (7)

1. Explain why the recursive Fibonacci program is so inefficient.

Answer: Each Fibonacci number is calculated multiple times. The larger the Fibonacci sequence, the
more redundant calculations are performed.

2. What is the value returned from the following method when it is called with the value 9?

int mystery (int n)


{
if (n < 1)
return 0;
else if (n % 2 == 0)
return mystery(n-1);
else return 1 + mystery(n-1);
}

Answer: 5

3. What does the following method compute?

int mystery (int n)


{
if (n < 1)
return 0;
else if (n % 2 == 0)
return mystery(n-1);
else return 1 + mystery(n-1);
}

Answer: The ceiling function of n / 2. Or the count of odd numbers up to n.

4. What is the value returned from the following method when it is called with the value 5?

int mystery(int x, int y)


{
if (y == 0)
return 1;
if (y == 1)
return x;
return x * mystery(x, y-1);
}

Answer: 32
5. What does the following method compute?

int mystery(int x, int y)


{
if (y == 0)
return 1;
if (y == 1)
return x;
return x * mystery(x, y-1);
}

Answer: It computes xy.

6. What does the following method compute?

boolean mystery(int[] x, int b, int c)


{
if (b > 0)
if (x[b-1] == c)
return true;
else
return mystery(x, b-1, c);
return false;
}

Answer: It returns true if the value of c is in the array x, otherwise it returns false. The variable b is
the size of the array x.

7. What does the following method compute?

int mystery(int[] x, int b, int c)


{
if (b > 0)
if (x[b-1] == c)
return b-1;
else
return mystery(x, b-1, c);
return -1;
}

Answer: It searches an array for the value of c. It returns the array index if the value is found, -1 if it
is not found. The variable b is the size of the array x.
Multiple Choice (25) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED
WITH **. YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.

1. A method that calls itself is called a


a. recursive method **
b. base method
c. iterative method
d. dynamic method

2. The condition when a recursive method does not satisfy a base case it is called
a. infinite recursion **
b. finite recursion
c. iterative recursion
d. baseless recursion

3. When too many recursive calls are made creating more activation records than the allocated
program memory can handle, what kind of error occurs?
a. stack overflow **
b. activation record overflow
c. recursive overflow
d. infinite recursion

4. What happens when a recursive method does not reach the base case?
a. the program crashes
b. a stack overflow occurs
c. both a & b **
d. none of the above

5. Recursion can be used to solve problems like


a. processing linked chains
b. processing arrays
c. sorting
d. all of the above **

6. Recursive methods
a. are useful when each recursive all is a solution to a smaller, identical problem **
b. do not use an if-statement
c. are not useful in programming
d. all of the above

7. Recursive methods need a(n)


a. base case **
b. for loop
c. trace
d. all of the above

8. What question should you keep in mind when debugging a recursive method?
a. Is there at least one recursive call?
b. Did you consider all possible cases?
c. Does the method contain a statement to test an input value and leads to different
cases?
d. All of the above. **

9. What question should you keep in mind when debugging a recursive method?
a. Does each base case produce a result that is correct for that case?
b. are there enough base cases?
c. Is at least one of the cases a base case that has no recursive call?
d. All of the above. **

10. What question should you keep in mind when debugging a recursive method?
a. If the method returns a value, does each of the cases return a value? **
b. Should a for-loop be included in the method?
c. Are the activation records correct?
d. All of the above.

11. A recursive method that processes a chain of linked nodes


a. uses the first node in the chain **
b. uses the last node in the chain
c. divides the chain in half placing the middle node in the left chain
d. divides the chain in half placing the middle node in the right chain

12. Traversing a chain of linked nodes


a. is easier to do recursively than iteratively **
b. is easier to do iteratively than recursively
c. is impossible to do recursively
d. is easy to do iteratively

13. To determine the efficiency of a recursive method you need to solve a(n)
a. recurrence relation **
b. recursive relation
c. quadratic equation
d. base case

14. The efficiency for recursively traversing a chain of linked nodes is


a. O(n) **
b. O(1)
c. O(n2)
d. it cannot be proven

15. The efficiency for recursively calculating xn is


a. O(log n) **
b. O(n log n)
c. O(n)
d. O(n2)

16. The efficiency for solving the Towers of Hanoi problem recursively is
a. O(2n) **
b. O(n2)
c. O(n)
d. O(log n)

17. The rate of growth for the Towers of Hanoi problem as the number of disks increases is
a. exponential **
b. quadratic
c. linear
d. constant

18. When the last action in a recursive method is a recursive call, it is called
a. tail recursion **
b. final recursion
c. delayed recursion
d. latent recursion

19. When method X calls method Y, method Y calls method Z, and method Z calls method X, this is
called
a. indirect recursion **
b. mutual recursion
c. tail recursion
d. an error

20. When method X calls method Y, and method Y calls method X, this is called
a. mutual recursion **
b. tail recursion
c. associative recursion
d. an error

21. What is the output of the following program when the method is called with 4?

void unknown(int n)
{
System.out.print("?");
if (n > 0)
unknown(n-1);
}

a. ????? **
b. ????
c. ???
d. none of the above

22. What is the output of the following program when the method is called with 4?

void unknown(int n)
{
if (n > 0)
{
System.out.print("?");
unknown(n-1);
}
}

a. ???? **
b. ?????
c. ???
d. none of the above

23. What is the output of the following program when the method is called with 4?

void unknown(int n)
{
if (n > 0)
unknown(n-1);
System.out.print("?");
}
a. ????? **
b. ????
c. ???
d. none of the above

24. How many recursive calls will be made if the following method is called with 6?

void greeting(int n)
{
System.out.println("Hello!");
greeting(n-1);
}

a. infinitely **
b. 7
c. 6
d. 5

25. How many recursive calls will be made if the following method is called with 6?

void greeting(int n)
{
if (n > 0)
{
System.out.println("Hello!");
greeting(n+1);
}
}

a. infinitely **
b. 7
c. 6
d. 5
Discovering Diverse Content Through
Random Scribd Documents
medium, a computer virus, or computer codes that damage or
cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES -


Except for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU
AGREE THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE,
STRICT LIABILITY, BREACH OF WARRANTY OR BREACH
OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE
TRADEMARK OWNER, AND ANY DISTRIBUTOR UNDER
THIS AGREEMENT WILL NOT BE LIABLE TO YOU FOR
ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE
OR INCIDENTAL DAMAGES EVEN IF YOU GIVE NOTICE OF
THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If


you discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person or
entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR
ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you do
or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status by
the Internal Revenue Service. The Foundation’s EIN or federal
tax identification number is 64-6221541. Contributions to the
Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or
determine the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.

Please check the Project Gutenberg web pages for current


donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

testbankfan.com

You might also like