Follows the standard splay tree insertion algorithm:
If tree is empty, create a new single-node tree
Otherwise, perform standard BST insertion
Splay the newly inserted element to the root
Note: If the element already exists, it will be splayed to root but no duplicate is added.
This maintains the BST property while ensuring the accessed element becomes the root.
Inserts a new element into the splay tree
Follows the standard splay tree insertion algorithm:
Note: If the element already exists, it will be splayed to root but no duplicate is added. This maintains the BST property while ensuring the accessed element becomes the root.