Problem 3

(a) O(n^2)
Simple nested loops

(b) O(n)
Two adjacent loops

(c) O(n^3)
Nested loops, having O(n) and O(n^2) repetitions respectively.

(d) O(n^2)
Two nested loops. The if() block is executed at most i times
for each value of j. So, total running time is the sum of i's
from 1 to n-1, which is (n-1)n/2.
(This is actually a bubblesort routine)

(e) O(n)
This routine has two loops nested, but O(n^2) is not the lowest
(best possible) bound. Each of lines 1~3 is executed at most n times.
For each value of j(=0, ..., n-1), while loop body is executed at most once,
since the loop body sets link[j] to -1 each time.
Hence its actual running time is O(n).
(This routine resets all link[i] values to -1)
