The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8,... Formall
ID: 3690420 • Letter: T
Question
The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8,...
Formally, it can be expressed as: fib(0) = 0, fib(1) = 1, fib(n) = fib(n 1) + fib(n 2)
Write a multithreaded program that generates the Fibonacci sequence. This program should work as follows:
On the command line, the user will enter the number of Fibonacci numbers that the program is to generate.
The program will then create a separate thread that will generate the Fibonacci numbers, placing the
sequence in data that can be shared by the threads (an array is probably the most convenient data structure).
When the thread nishes execution, the parent thread will output the sequence generated by the child thread.
Because the parent thread cannot begin outputting the Fibonacci sequence until the child thread nishes, the
parent thread will have to wait for the child thread to nish.
Explanation / Answer
Problem:
The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8,...
Formally, it can be expressed as: fib(0) = 0, fib(1) = 1, fib(n) = fib(n 1) + fib(n 2)
Write a multithreaded program that generates the Fibonacci sequence.
solution:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.