Data Structure

data-structure

#1

Any idea of how to implement a Data Structure that supports two operation in less than O(n) and the ds is sorted?
Insert
Delete


#2

BST(Binary Search Tree)

Insertion and Deletion Complexity: O(log2(n))


#3

@shawnfrost in bst its O(h) and worst case the insertion and deletion is O(n) anything better than that?


#4

AVL Tree.
They are same as BST but are height balanced.

So, h remain log2(n) always.


#5

how to delete in avl trees? and also like is there a way if i can find nth max in avl tree?


#6

Complete implementation is available on geeksforgeeks.

Consider maintaining count of nodes on the left and right of each node.

Now,perform binary search skipping all nodes before nth node.

O(log2(n)) per query.


#7

thanks !!!