Analyze Running Time Following Pseudocode Algorithms Express Running Time Big O Notations Q37081408

Analyze running time of the followingpseudocode/algorithms and express the running time in Big-Onotations. Show your work.

a.

// parameter n is a natural number

factorial (int n)

{

if n==0

return 1;

if n==1

return 1;

return n*factorial (n-1)

}

b.

// parameter n is a positive integer

int func(int n)

{

int step = 1;

while (n>1)

n = n/3;

step++;

return step;

}

c.

// The function’s input is a list of size n

func3 (L[1…n])

1. call func3 on the left half of list L

2. call func3 on the right half of list L

3. call func3 on the middle half of the list (i.e., thelist after removing the first 1/4 and the last 1/4 of thelist)

4. some additional processing that takes

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.