Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to write a code that finds element x in a skip list. I need to implement that in O(logk) expected running time, where k is the location of x at the list (i.e., there are k-1 elements before x in the list).

I know how to do it at o(logn), but not o(logk).

can you show me the way? I need only general description or pseudo code, not more than that.
Posted

1 solution

You can use finger search algorithm. It has the required running time, since it starts and ends at two nodes at the deepest level of a skip list. A variant of this algorithm is described and available in the article Efficient Representation of a Semigroup in C++[^], see Figure 1 for its illustration.

In general, note that level-linked B+ trees are better choice than skip lists, since they are deterministic data structures. In addition to this, I suggest measuring performance of both algorithms (top-down and finger search), if you are planning to use them in practical applications.

Regards,
Vadim Stadnik
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900