Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

I really need help please this problem is very confusing for me it is in C++

The Fibonacci sequence:
unsigned fibonacci (unsigned n, unsigned& recursions);
void fibonacci(unsigned f[], unsigned n);
The first function is to solve the problem recursively and return the Fibonacci value of n as the
result. In addition, it shall store the number of recursive calls in the recursions parameter.
For example, assume recursions is an unsigned int variable in main() and is set to 0 before
each of call to the fibonacci function.
Calling fibonacci (0, recursions) should return 1 and store 0 in recursions since
there is no need for recursive call.
●
Calling fibonacci (2, recursions) should return 2 and store 2 in recursions since
this call would have trigger two recursive calls: fibonacci (0, recursions) and
fibonacci (1, recursions).
Calling fibonacci (3, recursions) should return 3 and store 4 in recursions since
this call would first trigger fibonacci (2, recursions) and fibonacci (1,
recursions). In addition, fibonacci (2, recursions) would trigger fibonacci (1,
recursions) and fibonacci (0, recursions).
The second function is to create the first n values of the Fibonacci sequence and store them in
the array parameter using an iterative approach. Do not use any nested loop. For example,
assume results is an array of unsigned int.
Calling fibonacci (results, 5) should store {1, 1, 2, 3, 5} in the first five elements of
results.
Calling fibonacci (results, 10) should store {1, 1, 2, 3, 5, 8, 13, 21, 34, 55} in the first
ten elements of results.
expand button
Transcribed Image Text:The Fibonacci sequence: unsigned fibonacci (unsigned n, unsigned& recursions); void fibonacci(unsigned f[], unsigned n); The first function is to solve the problem recursively and return the Fibonacci value of n as the result. In addition, it shall store the number of recursive calls in the recursions parameter. For example, assume recursions is an unsigned int variable in main() and is set to 0 before each of call to the fibonacci function. Calling fibonacci (0, recursions) should return 1 and store 0 in recursions since there is no need for recursive call. ● Calling fibonacci (2, recursions) should return 2 and store 2 in recursions since this call would have trigger two recursive calls: fibonacci (0, recursions) and fibonacci (1, recursions). Calling fibonacci (3, recursions) should return 3 and store 4 in recursions since this call would first trigger fibonacci (2, recursions) and fibonacci (1, recursions). In addition, fibonacci (2, recursions) would trigger fibonacci (1, recursions) and fibonacci (0, recursions). The second function is to create the first n values of the Fibonacci sequence and store them in the array parameter using an iterative approach. Do not use any nested loop. For example, assume results is an array of unsigned int. Calling fibonacci (results, 5) should store {1, 1, 2, 3, 5} in the first five elements of results. Calling fibonacci (results, 10) should store {1, 1, 2, 3, 5, 8, 13, 21, 34, 55} in the first ten elements of results.
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

What are the pros and cons of using either the first or second function listed?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

What are the pros and cons of using either the first or second function listed?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education