Treap Visualizer
Treaps are very powerful and easy to implement data structures that allow us to do operations efficiently on an ordered set of elements that we would normally not be able to do. The treaps can be thought as dyanmic arrays. We can merge these different arrays, split arrays, reverse arrays, add elements to an array, and update and query certain properties over contigous ranges all in O(log(n)) with treaps, where n is number of the nodes. To find the array each treap corresponds to take the values in an inorder traversal of the treap, as if it was a normal binary tree. The implicit treaps represented below maintain a max-heap of randomly generated priorities(Prior) to maintain a log(n) expected height. The Size property of each node represents size of its subtree, which helps us make decisions at each node on the boundary. For more information, checkout CP-Algorithms blog on Cartesian Trees/Treaps.