Good code is its own best documentation. As you’re about to add a comment, ask yourself, ‘How can I improve the code so that this comment isn’t needed? Steve McConnell
A splay tree is a self-adjusting binary search tree with the additional property that recently accessed elements are quick to access again. The splay tree has good performance during the average case and uses small memory compare than another tree.
The main disadvantage is that the height of the splay tree is linear. It may be difficult to handle in the multithreaded environment. Splay tree reshape the nodes to know frequently access elements which improve the better lookup time. Splay trees can only guarantee that any sequence of n operations takes at most O (n log n) time.
Write a program to implement the splay tree with insert and remove operations.
Array of items insert into the splay tree:[45, 67, 34, 22, 89, 56, 78, 11] Splay tree items after insert into Splay tree using post order:34 56 45 89 78 67 22 11 Minimum item from Splay tree:11 Max item from Splay tree:89