0

I wanted to calculate the complexity of this pseudocode. In my knowledge, it is $n^2$ because the last loop only runs 8 times. I wrote a program to test it tends to run 8^logn (approximately). can you help me to find the correct answer_

1: procedure f(n)
2:   for i := 1 to n do
3:       for j := 1 to n do
4:           print(i)
5:           print(n)
6:       end for
7:   end for
8:   if n > 1 then
9:      for i := 1 to 8 do
10:         f([n/2])
11:     end for
12:  end if
13: end procedure

enter image description here

0 Answers0