Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ot committed Oct 17, 2012
1 parent 43f501d commit 8f76d48
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cartesian_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace succinct {

// This class implements a cartesian tree based RMQ data
// This class implements a cartesian-tree-based RMQ data
// structure, using the 2d-Min-Heap DFUDS representation described
// in "Space-Efficient Preprocessing Schemes for Range Minimum
// Queries on Static Arrays", Johannes Fischer and Volker Heun,
Expand Down Expand Up @@ -82,19 +82,21 @@ namespace succinct {
// the rest of the library?
uint64_t rmq(uint64_t a, uint64_t b) const
{
typedef bp_vector::excess_t excess_t;

assert(a <= b);
if (a == b) return a;

uint64_t n = size();

uint64_t t = m_bp.select0(n - b - 1);
bp_vector::excess_t exc_t = bp_vector::excess_t(t - 2 * (n - b - 1));
excess_t exc_t = excess_t(t) - 2 * (n - b - 1);
assert(exc_t - 1 == m_bp.excess(t + 1));

uint64_t x = m_bp.select0(n - b);
uint64_t y = m_bp.select0(n - a);

bp_vector::excess_t exc_w;
excess_t exc_w;
uint64_t w = m_bp.excess_rmq(x, y, exc_w);
assert(m_bp[w - 1] == 0);

Expand Down

0 comments on commit 8f76d48

Please sign in to comment.