GATE | GATE CS 2013 | Question 7
Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into a binary search tree of n nodes?
(A) O(1)
(B) O(Logn)
(C) O(n)
(D) O(nLogn)
Answer: (C)
Explanation: To insert an element, we need to search for its place first. The search operation may take O(n) for a skewed tree like following.
To insert 50, we will have to traverse all nodes.
10
\
20
\
30
\
40
Recommended Posts:
- GATE | GATE CS 2013 | Question 48
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 33
- GATE | GATE CS 2013 | Question 32
- GATE | GATE CS 2013 | Question 31
- GATE | GATE CS 2013 | Question 30
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 47
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 65
- GATE | GATE CS 2013 | Question 44



