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.
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
Comments
Leave a comment