A parallel implementation of the All Nearest Smaller Values (ANSV) algorithm by Berkman, Schieber, and Vishkin for comparison to the algorithm by Blelloch, Shun, and Zhao.
Three implementations of algorithms the ANSV problem:
- Sequential array-based solution with O(n) complexity.
- The Berkman, Schieber, and Vishkin optimal solution.
- The Shun and Zhao heuristic approach.
- CMake (minimum required version 3.16).
- C++20 Standard for modern C++ features.
- ParlayLib (header-only library) for efficient parallel computations.
- Pthread library for multithreading support.
- Ensure CMake (version 3.16 or higher) and a C++20 compliant compiler are installed.
- Clone this repository to your system.
- Ensure ParlayLib is cloned into your project. It's available on GitHub.
- Navigate to the project directory and run the following commands: cmake . make
- This will compile the ANSV2 executable.
- Execute the ANSV2 executable to run the algorithms.
- The main.cpp file serves as the entry point and can be modified to test different algorithms or inputs.
The ANSV problem has numerous applications in various domains, including but not limited to:
- Finding the min/max among n elements.
- Merging sorted lists.
- Constructing Cartesian trees.
- Monotone polygon triangulation.
- Range minimum queries.
- Parenthesis matching.
- Binary tree reconstruction. (For more details, see berkman1993)
-
[berkman1993] O. Berkman, B. Schieber, and U. Vishkin. 1993. "Optimal Doubly Logarithmic Parallel Algorithms Based On Finding All Nearest Smaller Values." Journal of Algorithms 14, no. 3 (1993): 344-370. DOI: 10.1006/jagm.1993.1018
-
[zhao2013] Julian Shun and Fuyao Zhao. 2013.** "Practical Parallel Lempel-Ziv Factorization." In 2013 Data Compression Conference. IEEE, 123–132. DOI: 10.1109/DCC.2013.20