How about a corner case, though?

2 years ago
10.4K

So, in the first trip through the loop,we update n from zero to 1,on the second trip through that same loop,we update n from 1 to 2.And so, by this algorithm's end, n is 2,which indeed matches the number of people in the room.So far, so good.How about a corner case, though?Suppose that there are zero people in the room,besides me, who's doing the counting.In line 1, we again initialize n to zero.

Loading comments...