CPSC 327 | Data Structures and Algorithms | Spring 2024 |
Order the following functions by growth rate, from slowest-growing to fastest growing. Provide justifications for your answer.
Give the worst-case running time for each of the following sets of loops. Remember that the total time for a loop is the sum of the time for each iteration - write the sum(s) and use the sums table to get the big-Oh for each. Assume that the ... steps take Θ(1) time.
for i = 1 to n do ...
for i = 1 to n do for j = 1 to i do ...
for i = 1 to n do for j = 1 to i do for k = j to i+j do ...
for i = 1 to n do for j = 1 to i do for k = j to i+j do for m = 1 to i+j-k do ...