The life and times of Zack Weinberg.
Tuesday, 10 August 2004
# 1:20 PM
another math problem
Really an algorithmics problem, I suppose. Some definitions: for any set s with ns elements, which are totally ordered:
Given a base set S with n totally ordered elements, find an algorithm which emits a list of medians, of the following sets in order:
and so on until all elements of the original set S have been emitted. In other words, the set is organized into a binary tree, each of whose subtrees corresponds to a subset of the original set, and is headed by the median element of that set; and then the tree is walked in breadth-first order.
The preferred solution is a nonrecursive algorithm with O(1) space requirement.