Currently FNBP cartesian tree used in the RMQ is built using a backward scan, this might create problems in the future. We'd like to support a build from a forward scan.
Possible solutions
- Add a "reverse" parameter to the template, meaning that all the buildup is done in reverse, with the backward scan becomes forward scan
- Change FNBP convention from ( left subtree ) right subtree to left subtree (right subtree). This will also allow us to buildup with forward scan
Both approaches break the leftmost tie-breaking, note specific tie-breaking is required by FNBP. The first variant simply reverses from leftmost min tie-breaking to rightmost, for the second variant additional excess primitives are probably required. Whether leftmost tie-breaking can be preserved with forward scan is not clear.
Currently FNBP cartesian tree used in the RMQ is built using a backward scan, this might create problems in the future. We'd like to support a build from a forward scan.
Possible solutions
Both approaches break the leftmost tie-breaking, note specific tie-breaking is required by FNBP. The first variant simply reverses from leftmost min tie-breaking to rightmost, for the second variant additional excess primitives are probably required. Whether leftmost tie-breaking can be preserved with forward scan is not clear.