An easy change to the algorithm improves the running time to
O(n2).
- How can we make the search for a free man (boy) take constant
time?
- How can we implement RANK to run in constant time? It needs
to, for example, take a boy b and a girl g and tell us where b
is on g's ROL. With some preprocessing, can do this with a single
array lookup.
Therefore, each iteration of the while loop takes constant time.
Total O(n2) time.
Next: UNDERSTANDING THE ALGORITHM
Up: THE MATCHING ALGORITHM
Previous: Time Analysis