[Solved] Time complexity of recursive algorithm (pseudo code)
First, let’s look at two simple nested loops first: for i (1..N) { for j (1..N) { f(); } } for i (1..N) { for j (i..N) { g(); } } f() is called N*N = N2 = O(N2) times. g() is called N+(N-1)+…+5+4+3+2+1 = N(N+1)/2 = N2/2 + N/2 = O(N2) times. As you … Read more