Question: Write a recurrence relation describing the worst case running time of each of the following algorithms and, unless told otherwise, determine the asymptotic complexity of

Write a recurrence relation describing the worst case running time of each of the following

algorithms and, unless told otherwise, determine the asymptotic complexity of the function

defined by the recurrence relation. Justify your solution using the method of substitution.

You may NOT use the Master Theorem.

Simplify your answers, expressing them in a form such as (f(n)) whenever possible

(where f(n) is one of the standard functions in the hierarchy). Throughout A[i..j] represents

an array of n = ji+1 integers starting at index i and ending at index j and A[k] represents

the value at index k.

1.) FUNCTION F1(A[1..n])

IF n 20 THEN RETURN(A[1])

FOR i 1 TO n 5 DO

FOR j 1 TO [n/2] DO n/2 is in a floor bracket

A[i] A[i] A[j] + A[2 j]

y F1(A[1..(n 3)])

RETURN(y)

2.) FUNCTION F2(A[1..n])

IF n 20 THEN RETURN(A[n])

x 0

FOR i 1 TO 5 DO

FOR j 1 TO n 10 DO

A[i] A[j] + A[j + 2]

x x + F2(A[1..[n/2] ]) n/2 is in a floor bracket

RETURN(x)

3.) FUNCTION F3(A[1..n])

IF n 20 THEN RETURN(A[1])

x F3(A[1..[2n/3] ]) 2n/3 is in a floor bracket

FOR i [n/4] TO [n/4] + 12 DO both n/4 is in a floor bracket

x x + A[i]

RETURN(x)

4.) FUNCTION F4(A[1..n])

IF n 20 THEN RETURN(A[n])

x F4(A[1..(n 4)]

i 1

WHILE i < n/2 DO

A[i] A[i] A[2 i]

i 3 i

x x + F4(A[11..n])

RETURN(x)

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