Given a sequence of n elements, the All Nearest Smaller Values (ANSV) problem is to find, for each element in the sequence, the nearest element to the left (right) that is smaller, or to report that no such element exists. Berkman, Schieber, and Vishkin (1993) give an ANSV algorithm that runs in O(lg n) time on an (n/lg n)-processor CREW PRAM. In this paper, we present an O(lg n)-time n-processor normal hypercube algorithm for the ANSV problem. Furthermore, we prove that any normal hypercube algorithm requires /spl Omega/(n) processors to solve the ANSV problem in O(lg n) time. We use our ANSV algorithm to give the first O(lg n)-time n-processor normal hypercube algorithms for triangulating a monotone polygon and for constructing a Cartesian tree.
展开▼