How can I find the number of comparisons in this algorithm?

343 Views Asked by At
procedure pair zeros(b1 b2 . . . bn : bit string, n ≥ 2) 
       x := b1
       y := b2
       k := 2
       while k < n and (x ̸= 0 or y ̸= 0)
           k := k + 1
           x := y
           y := bk
       if x = 0 and y = 0 then print “YES” 
       else print “NO”

I know that since we start checking from 2 and k < n, while will loop (n-2) times. But we have to multiply it with the number of comparisons. If condition is not inside the while loop, so I do not know if we count the comparisons there. I also might be wrong about what I said. So, please feel welcomed to correct me