# Time complexity of searching an element in Binary Search Tree [closed]

I want to know what will be the time complexity to search, insert and delete an element in a) balanced binary search tree. b) unbalanced binary search tree.

• What have you tried and where did you get stuck? Those results are utterly standard. Where did you look? – Raphael Nov 29 '17 at 10:38
• For balanced Binary search tree this is what i think , for searching (assuming element needed is at leaf position) we would require to search upto last level , just like binary search the problem gets divided each time till we get the element therfore O(log n)..i dont know its correct or not...for unbalanced i dont know where to start... – JobLess Nov 29 '17 at 10:50
• I suggest you pick up a text book that explains the basics and then this analysis to you. I recommend Sedgewick's books. – Raphael Nov 29 '17 at 10:54
• This is what is writeen in the text ". The running times of algorithms on binary search trees depend on the shapes of the trees, which, in turn, depends on the order in which keys are inserted." So if shape of the tree skews either left or right then all the nodes will be present on one side only.. So suppose that element to be found is at last level ... N nodes needs to be visited hence it is O(n) is it correct – JobLess Nov 29 '17 at 12:06

Best case time complexity for search, insertion, and deletion is O(log n). This would correspond to a balanced tree.
The worst case is O(n). This would correspond to the unbalanced tree
• You mean $\Omega(n)$. – Raphael Nov 29 '17 at 10:39