A SplayTree is a self-adjusting binary search tree that moves frequently accessed elements closer to the root. This self-adjusting property allows for efficient access to recently accessed elements, making it particularly useful for scenarios where certain elements are accessed more frequently than others.
import { SplayTree } from "collection-kit";
import { SplayTree } from "collection-kit";
const tree = new SplayTree();
tree.insert(10);
tree.insert(20);
tree.insert(5);
console.log("Search 20:", tree.search(20)); // true, 20 is now root
tree.remove(20);
console.log("Search 20:", tree.search(20)); // false