The median problem:
Write an algorithm to find the median element of an array,
that is, the one which would be in the middle if the
array were sorted.
You may assume that the array has an odd number of elements.
Hint:
If you use the Dutch National Flag algorithm to
partition the array, what can you deduce if the middle
element is (a) red; (b) white; (c) blue?
In cases (a) and (c), what will you do next?
[I will be quite happy with reasonably-detailed
pseudo-code, as this module is much more about strategy than
about the minutiae of particular computer languages;
but you may perhaps be happier if you write
real code in QBasic or C or whatever, so that you can test
your algorithm.]