MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / splay

Method splay

src/class153/FollowUp1.java:70–87  ·  view source on GitHub ↗
(int i, int goal)

Source from the content-addressed store, hash-verified

68 }
69
70 public static void splay(int i, int goal) {
71 int f = father[i], g = father[f];
72 while (f != goal) {
73 if (g != goal) {
74 if (lr(i) == lr(f)) {
75 rotate(f);
76 } else {
77 rotate(i);
78 }
79 }
80 rotate(i);
81 f = father[i];
82 g = father[f];
83 }
84 if (goal == 0) {
85 head = i;
86 }
87 }
88
89 // 整棵树上找到中序排名为rank的节点,返回节点编号
90 // 这个方法不是题目要求的查询操作,作为内部方法使用

Callers 6

addMethod · 0.95
rankMethod · 0.95
indexMethod · 0.95
preMethod · 0.95
postMethod · 0.95
removeMethod · 0.95

Calls 2

lrMethod · 0.95
rotateMethod · 0.95

Tested by

no test coverage detected