Above algorithm extremely inefficient

Assignment Help Basic Computer Science
Reference no: EM131498999

The code below is for a recursive solution to computing the nth Fibonacci number.

public long fibRecursive(int n)

{

   if (n <= 1)

   {

       return n;

   }

   else

   {

       return fibRecursive(n - 1) + fibRecursive(n - 2);

   }

}

Why is the running time for the above algorithm extremely inefficient? 

a) The recursive call, fibRecursive(n - 1) causes the algorithm to perform redundant calculations. 

b) The recursive call, fibRecursive(n - 2) causes the algorithm to perform redundant calculations. 

c) Both recursive calls cause the algorithm to perform redundant calculations. 

d) The algorithm is recursive, and is thus inherently inefficient. 

e) The recursive calls are performed in the wrong sequence; i.e., fibRecursive(n - 2) should be called before fibRecursive(n - 1). 

Reference no: EM131498999

Questions Cloud

Forensic image of a hard drive while on scene : Collect electronic evidence - list the tools and methods you would use to collect a forensic image of a hard drive while on scene.
Research essays for organizational behavior : Research Essays for Organizational Behavior. Explain how theories of organizational behavior may be applied in an organizational setting
About the expected interest rate : The real risk-free rate is 2.5%. What is the yield on 2-year Treasury securities? What is the yield on 3-year Treasury securities?
Identify developmental milestones throughout the lifespan : Demonstrate understanding of key concepts and terms in lifespan development. Identify developmental milestones throughout the lifespan.
Above algorithm extremely inefficient : Why is the running time for the above algorithm extremely inefficient?
Define financial-accounting systems : Although the styles and details may have changed, the shirts, skirts, and jackets we wear today aren't a whole lot different than what was worn a decade ago.
Describe the main drivers for creating the model : In describing the OSI model, describe the main drivers for creating the model?
Disaster recovery-forensics-security : In a large organization, the goals and objectives of each business unit may give those units more of a small organization flavor.
Find implications for strategically managing an organization : Jack Welch, former CEO of General Electric, was noted for his managerial skills and abilities. The secret to his success was described as not a series.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Types of normalization

What are the various types of normalization? Please explain

  Check on average department salaries

What privileges should be granted to a user who needs to know only average department salaries for the Toy and CS departments?

  Generalization and aggregation in er diagrams

Explain the concept of generalization and aggregation in ER diagrams. Give one example for each one of them.

  Draw a connected graph that contains these vertices

Suppose that five vertices are arranged at the corners of an imaginary pentagon. Draw a connected graph that contains these vertices.

  The success of 24-bit digital audio technologies

3. A company noting the success of 24-bit digital audio technologies compared to earlier 16-bit digital audio technologies has decided to work on developing a 28-bit digital audio technology. a. Describe the type of signal conversion being utilized a..

  Draw an object diagram

Note, in particular, that the filter variable in make Menu Bar has been declared as final, as discussed in Section 11.4.8. Make sure that you understand why this is necessary.

  Information systems lifecycle and the database system

Discuss the relationship between the information systems lifecycle and the database system development lifecycle?

  Determine the rational zeros

Find the number of possible positive real zeros and the number of possible negative real zeros for each function. Then determine the rational zeros.

  Create variables and call modules

Create variables and call modules.

  Describe the qualities of valuable information

Describe the qualities of valuable information. Describe the different data types used in the fields of a database. Describe and explain how the different methods of validating data are used in a database.

  What are the degrees of freedom for the error term

Fifteen subjects were included in each group. The same test was administered prior to and after the treatments. If both pretest and IQ are used as covariates, what are the degrees of freedom for the error term?

  How reliable does an atm connection have to be in order

How reliable does an ATM connection have to be in order to maintain a loss rate of less than one per million for a higher-level PDU of size 20 cells? Assume AAL5.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd