# Blog

## How many children can a node have in a binary tree? Therefore, searching in binary search tree has worst case complexity of O(n). In general, time complexity is O(h) where h is height of BST. Insertion: For inserting element 0, it must be inserted as left child of 1.Nov 22, 2018

## What is the worst case complexity of binary search tree?

• Therefore, searching in binary search tree has worst case complexity of O(n). In general, time complexity is O(h) where h is height of BST. Insertion: For inserting element 0, it must be inserted as left child of 1. Therefore, we need to traverse all elements (in order 3, 2, 1) to insert 0 which has worst case complexity of O(n).

## Which tree has worst case time complexity of O(n)?

• Solution: As discussed, search operation in binary tree and BST have worst case time complexity of O (n). However, AVL tree has worst case time complexity of O (logn). So, the correct option is (D).

## What happens when a binary search tree is not balanced?

• Unfortunately when the tree is not balanced the time it takes to perform a search grows, which is very much a possibility with a binary search tree. This is because the searches depend on the height of the binary search tree. The worst case scenario is when a binary search tree is fully degenerate, a binary search tree is a chain of n nodes.  