input = integer n, array a[1..n]
output = integer w, arrayb[1..w], array c[1..w]
w = 0
while (true){
k = 1;
while (a[k] is equal to nil) do
k++;
if k equals n +1 then halt algorithm
end while
w++;
b[w] = a[k];
c[w] = 1;
a[k] = nil
for j = k+1 through n do
if a[j] and b[w] contain the same value then
c[w] = c[w] + 1;
a[j] = nil
end if
end for
end while
I am confused on how many times the inner while loop and the outer while loop executes how many times? As far as I can do the inner loop goes n(n+1)/2 times and the outer loop goes n times. is this right?? The way I found this solution is by writing this code into Java and prints out a counter on how many times the inner and outer while loop is executed. Though I am not quite sure if this is the right way, so I would like to make sure if you guys could give me a better tips. Thanks guys for all the comments and help.