
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
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.](https://content.bartleby.com/qna-images/question/46c0fb16-724b-4726-818c-9156075ac6cc/eeb51e34-70ea-4333-8303-cabdc2e9c7d2/i0kpdcn_thumbnail.png)
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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

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
by Bartleby Expert
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
by Bartleby Expert
Knowledge Booster
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
- This is very helpful thank you. If possible can you please show me how to make the function with the original parameters C++arrow_forwardNeed help figuring out this program and typing it in c++.arrow_forwardTranslate the arithmetic expression into: a) A syntax tree. b)Quadruples. c) Triples d)indirect triplesarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education