Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Splay tree
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Splaying === When a node ''x'' is accessed, a splay operation is performed on ''x'' to move it to the root. A splay operation is a sequence of ''splay steps'', each of which moves ''x'' closer to the root. By performing a splay operation on the node of interest after every access, the recently accessed nodes are kept near the root and the tree remains roughly balanced, so it provides the desired amortized time bounds. Each particular step depends on three factors: * Whether ''x'' is the left or right child of its parent node, ''p'', * whether ''p'' is the root or not, and if not * whether ''p'' is the left or right child of ''its'' parent, ''g'' (the ''grandparent'' of ''x''). There are three types of splay steps, each of which has two symmetric variants: left- and right-handed. For the sake of brevity, only one of these two is shown for each type. (In the following diagrams, circles indicate nodes of interest and triangles indicate sub-trees of arbitrary size.) The three types of splay steps are: '''Zig step:''' this step is done when ''p'' is the root. The tree is rotated on the edge between ''x'' and ''p''. Zig steps exist to deal with the parity issue, will be done only as the last step in a splay operation, and only when ''x'' has odd depth at the beginning of the operation. [[File:splay tree zig.svg|center|350px]] '''Zig-zig step:''' this step is done when ''p'' is not the root and ''x'' and ''p'' are either both right children or are both left children. The picture below shows the case where ''x'' and ''p'' are both left children. The tree is rotated on the edge joining ''p'' with ''its'' parent ''g'', then rotated on the edge joining ''x'' with ''p''. Zig-zig steps are the only thing that differentiate splay trees from the ''rotate to root'' method introduced by Allen and Munro<ref name="AllenMunro">{{harvnb|Allen|Munro|1978}}.</ref> prior to the introduction of splay trees. [[Image:Zigzig.gif|center]] '''Zig-zag step:''' this step is done when ''p'' is not the root and ''x'' is a right child and ''p'' is a left child or vice versa (''x'' is left, ''p'' is right). The tree is rotated on the edge between ''p'' and ''x'', and then rotated on the resulting edge between ''x'' and ''g''. [[Image:Zigzag.gif|center]]
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Splay tree
(section)
Add topic