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

Method splay

src/class153/Code04_Bookcase1.java:82–99  ·  view source on GitHub ↗
(int i, int goal)

Source from the content-addressed store, hash-verified

80 }
81
82 public static void splay(int i, int goal) {
83 int f = father[i], g = father[f];
84 while (f != goal) {
85 if (g != goal) {
86 if (lr(i) == lr(f)) {
87 rotate(f);
88 } else {
89 rotate(i);
90 }
91 }
92 rotate(i);
93 f = father[i];
94 g = father[f];
95 }
96 if (goal == 0) {
97 head = i;
98 }
99 }
100
101 // 返回中序排名为rank的节点编号
102 public static int find(int rank) {

Callers 4

addMethod · 0.95
askMethod · 0.95
queryMethod · 0.95
moveMethod · 0.95

Calls 2

lrMethod · 0.95
rotateMethod · 0.95

Tested by

no test coverage detected