Determine the worst-case time complexity of the following


Determine the worst-case time complexity of the following pseudocode algorithm. Assume that DoOtherStuff has a time complexity of O(n) where n = r-l. Show all calculations, justify your answer.

Algorithm DoStuff ( a, l, r )
'a' is an array of numbers
'l' and 'r' are positive integers between 0 and (a.length -1)

int m = ( l + r ) / 2;
if( l < r )
DoStuff(a, l, m)
DoStuff(a, m+1, r)
DoOtherStuff(a,l,m,r)

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Determine the worst-case time complexity of the following
Reference No:- TGS02382680

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)