i feel has exist, can't think of it. there data structure can 1 hold sorted list of values , searched (maybe log(n) time array), , supports insertion , removal of elements in log(n) or constant time?
this pretty description of balanced binary search tree, stores elements in sorted order, allows o(log n) insertions, deletions, , lookups, , allows o(n) traversal of elements.
there many ways build balanced bst - there red/black trees, avl trees, scapegoat trees, splay trees, aa trees, treaps, (a, b)-trees, etc. of these solve problem. of them, splay trees easiest code up, followed aa-trees , avl trees.
hope helps!
Comments
Post a Comment