Suppose I have been given a skip list, with order 3.
HEAD
level 3 |--------------------------------------------> X
| |---|
level 2 | -------------------> | | ----------------> X
| |---| |---| |---| |---|
level 1 | -> | | -> | | -> | | -> | | -------> X
| |---| |---| |---| |---|
| | 20| |100| |150| |200|
| |---| |---| |---| |---|
minlimit = ceil(order/2) - 1 = 1
maxlimit = order - 1 = 2
So essentially this is a 1-2 skip-list.
If I want to paste 50using the insertion algorithm from top to bottom, it will raise the node level 100before moving on to the gap between Headand 150and paste 50to the right to 100. Now the violation will occur, since there are no nodes between 100and 150, while in this space there should be at least a node of height h-1.
What am I doing wrong?
source
share