Question: 1. Exercise 3.7 of the textbook. An algorithm prints the following pattern: * * * * * * * * * * * * *
1. Exercise 3.7 of the textbook.
An algorithm prints the following pattern:
*
* *
* * *
* * * *
* * * * *
A. What are the basic operations performed by the algorithm that you would count towards its running time?
B. Count the number of these basic operations for the specific output shown above.
C. The number of lines printed in the preceding pattern is 5. Assume that the algorithm can extend this pattern for any number of lines (line number i has i stars). If the number of lines, n is the input to the algorithm, how many basic operations are performed as a function of n?
D. Write your answer to the above question as a big O order.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
