Question: Problem 3 . Each of the algorithms below takes as input a positive integer n and then performs some steps. For each algorithm, state the

Problem 3. Each of the algorithms below takes as input a positive integer n and then performs some steps.
For each algorithm, state the running time of the algorithm as a function of n, using \Theta -notation.
(15 points)
a) For i =1 to n/3
j 10
While (j <= i/20)
Do placeholder stuff that takes O(1) time
j j +10
b) While (n >=1)
n n/3
do placeholder stuff that takes O(1) time.
c) While (n >=2)
n
n
Do placeholder stuff that takes O(1) time.
d) For i =1 to n
For j =1 to i
2
Do placeholder stuff that takes O(1) time
e) For i =1 to n
For j =1 to log(i)
For k =1 to n
Do placeholder stuff that takes O(1) time

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 Programming Questions!