binary-search-treeheapcomplexity-theorytreap

Treap Data Structure


The height of Treap is said to be logarithmic in order. But while performing an online insertion for given key (1,2),(1,3),(3,4),(4,5) in order, the height of the treap is of the order of input.

So the worst case complexity is turning out to be linear. Any suggestions.


Solution

  • Two things are given:

    So the runtime can be considered (amortized) Log(n) (average runtime with the same (worst case) data).