Answer to Question #254266 in Algorithms for Shanu

Question #254266

A. The Fibonacci numbers are the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..

B. Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example, factorial of 6 is 6*5*4*3*2*1 which is 720.

         n! = n * (n - 1) * …….. 1 

Define what an algorithm is and outline the characteristics of a good algorithm. Write the algorithms to display the Fibonacci series and the factorial value for a given number using Pseudo code. Determine the steps involved in the process of writing and executing a program. 

Take a sample number and dry run the above two algorithms. Show the outputs at the end of each iteration and the final output. Examine what Big-O notation is and explain its role in evaluating efficiencies of algorithms. Write the Python program code for the above two algorithms and critically evaluate their efficiencies using Big-O notation.



1
Expert's answer
2021-10-20T23:55:34-0400

A)



START

   Step 1  Declare variables A, B, C,n

   Step 2  Set A = 0, B = 0

   Step 3  DISPLAY A, B

   Step 4  C = A + B

   Step 5  DISPLAY C

   Step 6  Set A = B, B = C

   Step 7  REPEAT from 4 - 6, for n times

STOP



B)



Start

   Step 1: Declare variables n, fact, i

   Step 2: Read number from User

   Step 3: Initialize variables fact=1 and i=1

   Step 4: Repeat Until i<=number

            4.1 fact=fact*i

            4.2 i=i+1

   Step 5: Print fact

Stop


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS