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

  Calculate the average of first 8 numbers

Write a C++ program that: Calculate the average of first 8 numbers divisible by 3 or 5, but not 6 and 10. please send me the correct code first you try , i mean run and compile the code by yourself if it works then post it to me ,else i don't need..

  Recommendation for either staying

Recently, your manager has heard about IPv6 and has asked you to present a recommendation for either staying with IPv4 or moving to IPv6. What would you recommend and why? Consider issues such as manageability, cost, and security.

  How will you declare the boundaries of the transaction

Suppose that you are writing a stored procedure to change values in the CUSTOMER table. What transaction isolation level will you use?

  Describe the main elements of data breach notification

From the e-Activity, describe the main elements of data breach notification laws. Discuss the importance of breach notification for credit card information, as it relates to PCI-DSS.

  Create an executable file and enable set-user-id permission

Log in as a normal, unprivileged user, create an executable file (or copy an existing file such as /bin/sleep), and enable the set-user-ID permission bit on that file (chmod u+s). Try modifying the file (e.g., cat >> file). What happens to the fil..

  What purposes do views serve

What is the limitation on SELECT statements used in SQL views?

  Develop a contingency plan for ipremier

Develop a contingency plan for iPremier to be better prepared for similar future events

  Define new derived volumetric objects as volumetric union

This same idea can be applied to a general CSG expression tree. (Note that a general CSG object may be non-convex and thus the intersection between a ray and a general CSG object may be composed of several intersection intervals.)

  Describe the view integration through points

You have the choice to describe the view integration through points or attach a graphical view pattern that describes it.

  Design and test using logic works

Design and test using Logic Works a dual-output function to implement a full-adder in Sum-of-Products form. Show the transistor count on your schematic.

  Define a class star

Define a class Star. One parameter should be the number of points. Draw a few stars with differing numbers of points, differing line colors, and differing fill colors.

  Argument to the function

Write the code to call a function whose name is send_number. There is one argument for this function, which is an int. Send 5 as an argument to the function.

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