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

Method splay

src/class201/Code07_Network1.java:103–123  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

101 }
102
103 public static void splay(int x) {
104 int siz = 0;
105 sta[++siz] = x;
106 for (int y = x; !isroot(y); y = fa[y]) {
107 sta[++siz] = fa[y];
108 }
109 while (siz != 0) {
110 down(sta[siz--]);
111 }
112 while (!isroot(x)) {
113 int f = fa[x];
114 if (!isroot(f)) {
115 if (lr(x) == lr(f)) {
116 rotate(f);
117 } else {
118 rotate(x);
119 }
120 }
121 rotate(x);
122 }
123 }
124
125 public static void access(int x) {
126 for (int y = 0; x != 0; y = x, x = fa[x]) {

Callers 5

accessMethod · 0.95
makerootMethod · 0.95
findrootMethod · 0.95
splitMethod · 0.95
updateNodeMethod · 0.95

Calls 4

isrootMethod · 0.95
downMethod · 0.95
lrMethod · 0.95
rotateMethod · 0.95

Tested by

no test coverage detected