previous | start | next

The rank and select Methods

For an ordered symbol table st, the rank and select methods provide access through the position of the keys in the natural ordering.

int rank(Key k)

st.rank(k) should return the number of keys in st that are less than k.

If st.rank(k) returns 0, is the key k contained in st or not? What if st.rank(k) returns 1? What if st.rank(k) returns n where n = st.size()?

Key select(int i)

st.select(i) should return

See code examples



previous | start | next