-
Notifications
You must be signed in to change notification settings - Fork 7k
Open
Description
跳表的插入有这样的一段代码:
Node update[] = new Node[level];
for (int i = 0; i < level; ++i) {
update[i] = head;
}
Node p = head;
// 在 update 数组中记录每一层中小于value的最大的那个value
for (int i = level - 1; i >= 0; --i) {
while (p.forwards[i] != null && p.forwards[i].data < value) {
p = p.forwards[i];
}
update[i] = p;
}
我理解
for (int i = 0; i < level; ++i) {
update[i] = head;
}
是多余的,因为下面的for循环会给各个层的update数组赋值
Metadata
Metadata
Assignees
Labels
No labels