b. The reason that the recursive algorithm is so slow is because the algorithm used to simulate recursion. To compute FN, there is one call to FN-1 and FN-2. However, since FN-1 recursively makes a call to FN-2and FN-3, there are actually two separate calls to compute FN-2. If one traces out the entire algorithm, then we can see that FN-3 is computed three times, FN-4 is computed five times, FN-5 is computed eight times, and so on. As shown Figure Q2b, the growth of redundant calculations is expensive.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
b. The reason that the recursive algorithm is so slow is because the algorithm used to
simulate recursion. To compute FN, there is one call to FN-1 and FN-2. However,
since FN-1 recursively makes a call to FN-2and FN-3, there are actually two
separate calls to compute FN-2. If one traces out the entire algorithm, then we can
see that FN-3 is computed three times, FN-4 is computed five times, FN-5 is
computed eight times, and so on. As shown Figure Q2b, the growth of redundant
calculations is expensive.
F6.
„F5
F4
F3
F3
'F2
F3
F2
FI FI FO
FI FO
`F2
F2
FI
FI FI FO FI FO
FI FO
Figure Q2b
Write a pseudo code that will reduce the time complexity from o (2n ) to O (n)
class of efficiency.
Transcribed Image Text:b. The reason that the recursive algorithm is so slow is because the algorithm used to simulate recursion. To compute FN, there is one call to FN-1 and FN-2. However, since FN-1 recursively makes a call to FN-2and FN-3, there are actually two separate calls to compute FN-2. If one traces out the entire algorithm, then we can see that FN-3 is computed three times, FN-4 is computed five times, FN-5 is computed eight times, and so on. As shown Figure Q2b, the growth of redundant calculations is expensive. F6. „F5 F4 F3 F3 'F2 F3 F2 FI FI FO FI FO `F2 F2 FI FI FI FO FI FO FI FO Figure Q2b Write a pseudo code that will reduce the time complexity from o (2n ) to O (n) class of efficiency.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY