The algorithm was considered flawed

2 years ago
10.3K

But what if there are 3 people in the room?How does this algorithm fair?Let's see.In line 1, we initialize n to zero.Suppose next that there are zero people in the room.And so, by this algorithm's end,n is still 2, which isn't correct.Indeed this algorithm is said to be buggy because it has a mistake.Let's redress with some new pseudocode.Let n equal zero.For each pair of people in room,set n = n + 2.If 1 person remains unpaired,set n = n + 1.

Loading comments...