Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.A recursive definition is a definition (choose the best answer): A.where a base case is defined. B.that is recursive. C.that repeats itself. D.which uses a

1.A recursive definition is a definition (choose the best answer):

A.where a base case is defined.

B.that is recursive.

C.that repeats itself.

D.which uses a mathematical equation.

F.in which something is defined in smaller terms of itself.

2.If a recursive method does not have a base case:

A.a syntax error is identified.

B.an exception will be thrown.

C.it will operate more efficiently.

D.it will run forever.

E.it must have two recursive cases.

3.As one method calls another which calls another, their corresponding activation records are stored:

A.on a stack.

B.in a queue.

C.in static memory.

D.on a disk.

E.None of these is correct.

4.Factors to consider when deciding whether to use a recursive approach include:

A.time efficiency.

B.space efficiency.

C.clarity.

D.amount of recursive overhead.

E.All of these are correct.

5.The following code is supposed to return n!, for positive n. An analysis of the code using our "Three Question" approach reveals that:

int factorial (int n){

if (n > 0)

return (n * factorial(n - 1));

}

A.it fails the base-case question.

B.it fails the smaller-caller question.

C.it fails the general-case question.

D.it passes on all three questions and is a valid algorithm.

E.None of these is correct.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions