Splay tree
Splay tree is a self-adjusting binary search tree with the additional property that recently accessed elements are quick to access again. It performs basic operations such as insertion, look-up, and removal in amortized time complexity of O(log n) for n elements. This performance is comparable to other trees that balance height, such as AVL trees, but is achieved through a different mechanism known as splaying. Splaying not only helps with balancing the tree but also ensures that frequently accessed elements are moved closer to the root, making subsequent accesses faster.
Overview[edit]
A splay tree works by performing a splay operation on every access (including insertion, search, and deletion), which moves the accessed element to the root of the tree through a series of tree rotations. The splay operation is designed to not only move the accessed element to the root but also to partially rebalance the tree, improving the efficiency of future operations.
Operations[edit]
Splay Operation[edit]
The splay operation is central to the splay tree's functionality. It involves rotating the accessed node until it becomes the root of the tree. This is achieved through a series of specific rotations based on the node's position relative to its parent and grandparent: zig, zig-zig, and zig-zag.
Insertion[edit]
To insert a new element, the tree first performs a standard binary search tree insertion. After the element is inserted, a splay operation is performed on the inserted node, moving it to the root.
Search[edit]
When searching for an element, a binary search is performed. Regardless of whether the element is found, the last accessed node (either the node that was searched for or the last node accessed during the search) is splayed to the root.
Deletion[edit]
To delete an element, the tree first splays the target element to the root. Then, the tree is split into two subtrees: one containing all elements less than the deleted element and another containing all elements greater. These two trees are then joined, with the root of the joined tree being the minimum element of the right subtree after another splay operation.
Advantages and Disadvantages[edit]
The main advantage of splay trees is their ability to adapt to the sequence of operations performed on them, providing efficient access to frequently accessed elements. This makes them particularly useful in applications where access patterns are not uniform or predictable.
However, splay trees can have poor worst-case performance for individual operations, and the tree can become unbalanced if the access pattern is not sufficiently random or if there are long sequences of operations on elements that are far apart in the key space.
Applications[edit]
Splay trees are used in various applications that require efficient, adaptable, and easy-to-implement data structures for non-uniform access patterns. Examples include implementing caches, memory allocators, and data compression algorithms.
See Also[edit]
This computer science-related article is a stub. You can help WikiMD by expanding it.
-
Splay tree zig operation
-
Splay tree zig-zig operation
-
Splay tree zig-zag operation
Ad. Transform your life with W8MD's Budget GLP-1 injections from $75


W8MD offers a medical weight loss program to lose weight in Philadelphia. Our physician-supervised medical weight loss provides:
- Weight loss injections in NYC (generic and brand names):
- Zepbound / Mounjaro, Wegovy / Ozempic, Saxenda
- Most insurances accepted or discounted self-pay rates. We will obtain insurance prior authorizations if needed.
- Generic GLP1 weight loss injections from $75 for the starting dose.
- Also offer prescription weight loss medications including Phentermine, Qsymia, Diethylpropion, Contrave etc.
NYC weight loss doctor appointmentsNYC weight loss doctor appointments
Start your NYC weight loss journey today at our NYC medical weight loss and Philadelphia medical weight loss clinics.
- Call 718-946-5500 to lose weight in NYC or for medical weight loss in Philadelphia 215-676-2334.
- Tags:NYC medical weight loss, Philadelphia lose weight Zepbound NYC, Budget GLP1 weight loss injections, Wegovy Philadelphia, Wegovy NYC, Philadelphia medical weight loss, Brookly weight loss and Wegovy NYC
|
WikiMD's Wellness Encyclopedia |
| Let Food Be Thy Medicine Medicine Thy Food - Hippocrates |
Medical Disclaimer: WikiMD is not a substitute for professional medical advice. The information on WikiMD is provided as an information resource only, may be incorrect, outdated or misleading, and is not to be used or relied on for any diagnostic or treatment purposes. Please consult your health care provider before making any healthcare decisions or for guidance about a specific medical condition. WikiMD expressly disclaims responsibility, and shall have no liability, for any damages, loss, injury, or liability whatsoever suffered as a result of your reliance on the information contained in this site. By visiting this site you agree to the foregoing terms and conditions, which may from time to time be changed or supplemented by WikiMD. If you do not agree to the foregoing terms and conditions, you should not enter or use this site. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates, categories Wikipedia, licensed under CC BY SA or similar.
Translate this page: - East Asian
中文,
日本,
한국어,
South Asian
हिन्दी,
தமிழ்,
తెలుగు,
Urdu,
ಕನ್ನಡ,
Southeast Asian
Indonesian,
Vietnamese,
Thai,
မြန်မာဘာသာ,
বাংলা
European
español,
Deutsch,
français,
Greek,
português do Brasil,
polski,
română,
русский,
Nederlands,
norsk,
svenska,
suomi,
Italian
Middle Eastern & African
عربى,
Turkish,
Persian,
Hebrew,
Afrikaans,
isiZulu,
Kiswahili,
Other
Bulgarian,
Hungarian,
Czech,
Swedish,
മലയാളം,
मराठी,
ਪੰਜਾਬੀ,
ગુજરાતી,
Portuguese,
Ukrainian