MC logo

Loser Tree Merge


CS 402 Examples

Here are the steps of the loser tree merge example discussed in class. They are simply indexed here by step number, and the steps are linked together. Step zero is the original.

When a number is output, the number following enters as a leaf, and moves up by levels toward the root. As you move up, you carry the winner along. At each level, you find the loser of the last contest at that level. The node you are carrying challenges this previous loser. If it wins, you take it on to the next level. If it loses, you leave it and take the winner (the number which was there before you came) along to the next level. The winner of the contest at the root is placed the "extra" overall winner slot.

For instance, after step 1, 44 is output and replaced by 55. We start carrying 55 and head toward the root. We 55 beats 80, so we continue with 55. Then 55 loses to 48, so we leave 55 there and pick up 48. At the root, the contest is 48 v 48. One stays and the other one moves on to the winner's circle.


Step: 0123456789101112