Home > OS >  time complexity of inserting n number of nodes into an empty height balanced binary search tree usin
time complexity of inserting n number of nodes into an empty height balanced binary search tree usin

Time:07-09

I would like to know:

  • what would be the worst case time complexity of inserting n number of nodes into an empty height balanced binary search tree using recursion?

I know that the worst case time complexity of inserting one node into a balanced BST is O(logn). but I am confused as to whether its the same case when I insert node into an empty balanced BST.

CodePudding user response:

Insert into an empty tree would would initialize a root pointer and a data node. This would be constant time operation.

  • Related