Search code examples
crecursiontime-complexitybig-obinary-search-tree

time complexity of inserting n number of nodes into an empty height balanced binary search tree using recursion?


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.


Solution

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