1,659 views
3 votes
3 votes

What is the time complexity for insertion in binary tree in worst case?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n log n)

4 Answers

2 votes
2 votes

Image result for left skewed binary tree

 

For inserting element as the left child of D(either in a left-skewed binary tree or right skewed binary tree), we have to traverse all elements(i.e. A, B, C, D). Therefore, insertion in the binary tree has worst-case complexity of O(n).

0 votes
0 votes
In the worst case tree will be skewed therefore complexity will be O(n)

Related questions

3 votes
3 votes
4 answers
1
manikgupta123 asked Apr 29, 2019
1,766 views
What is the time complexity to delete an arbitrary node from binary heap?O(n)O(log n)O(1)O(n log n)
1 votes
1 votes
4 answers
2
manikgupta123 asked Apr 29, 2019
1,304 views
Which of the following gives O(1) complexity if we want to check whether an edge exists between two given nodes in a graph?Adjacency ListAdjacency MatrixIncidence MatrixN...
0 votes
0 votes
1 answer
3
manikgupta123 asked Apr 29, 2019
970 views
Which part in 8086 microprocessor is responsible for fetching instructions into the queue?BIUEUStackRegisters
3 votes
3 votes
2 answers
4
manikgupta123 asked Apr 28, 2019
1,086 views
How many pairs of positive integers do $m$ and $n$ satisfy in $\frac{1}{m}+\frac{4}{n}=\frac{1}{12}, $ where $n$ is odd and less than $60?$3579