Created
February 18, 2015 11:56
-
-
Save m0ar/292946ffb1421865f319 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void splay(Entry e){ | |
if(e == null || e == root) | |
return; | |
if(e.parent == root){ | |
if(e == e.parent.right) { | |
zig(e.parent); | |
root = e.parent; | |
return; | |
}else { | |
zag(e.parent); | |
root = e.parent; | |
return; | |
} | |
} | |
if(e == e.parent.right && e.parent == e.parent.parent.right) { | |
zigzig(e.parent.parent); | |
splay(e.parent.parent); | |
}else if(e == e.parent.left && e.parent == e.parent.parent.left) { | |
zagzag(e.parent.parent); | |
splay(e.parent.parent); | |
}else if(e == e.parent.left && e.parent == e.parent.parent.right){ | |
zagzig(e.parent.parent); | |
splay(e.parent.parent); | |
}else { | |
zigzag(e.parent.parent); | |
splay(e.parent.parent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment