Question: Control structures 2. A method shall calculate the Fibonacci numbers and store them in an array. The steps below (I to VI) describe the necessary

 Control structures 2. A method shall calculate the Fibonacci numbers and

Control structures 2. A method shall calculate the Fibonacci numbers and store them in an array. The steps below (I to VI) describe the necessary steps. Draw a Nassi-Shneiderman diagram to visualize the steps for this algorithm, using the steps listed below. 1) The method is called fibonacci' and returns an array of integer values. II) An integer named 'Size OfArray is the input parameter. This defines the number of Fibonacci numbers to calculate. The minimum size is 2. III) Initialize a new array object named 'result with the given size 'Size OfArray' IV) Initialize this array's elements: the element with the index 0 with the value zero and the element with the index 1 with the value 1. V) Iterate over the array result' starting from index 2 up to (size OfArray - 1) VI) Calculate each array's element as the sum of values of the two prior elements as shown in the Figure below. The numbers depicted in the upper left corner of the boxes in the figure are the indices and the numbers in the center area are the integer values of the array's elements. + + 0 2 3 4 5 6 0 1 1 2 3 5 ... + + +

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!