47.4k views
4 votes
Binary Search Tree containing N keys: INSERTing a new key has worst case time complexity of ...

a) O(log N)
b) O(N)
c) O(N²)
d) O(1)

1 Answer

3 votes

Final answer:

The worst case time complexity for inserting a new key in a binary search tree containing N keys is O(log N).

Step-by-step explanation:

The correct answer is a) O(log N). When inserting a new key into a binary search tree containing N keys, the worst-case time complexity is O(log N). This is because the binary search tree has a hierarchical structure that allows for efficient search and insertion operations. The height of a balanced binary search tree is log N, and since the worst-case time complexity is determined by the height of the tree, it is O(log N). For example, if a binary search tree has 16 nodes, the maximum height of the tree is log2(16) = 4, indicating that it will take at most 4 comparisons to find the correct position for a new key during insertion.

User Bullgare
by
7.9k points