Question
What is the time complexity of searching an element in
a balanced binary search tree (BST) with nnn nodes?Solution
In a balanced binary search tree (BST) , the height of the tree is maintained as O(log n)), ensuring that each level of the tree splits the search space roughly in half. This property allows searching for an element in the tree with logarithmic time complexity. For example, consider a balanced BST with 15 nodes. The height is approximately log 215≈4, so searching for any element will involve checking at most 4 nodes from the root to a leaf. The logarithmic reduction at each step (halving the search space) makes this approach efficient for large datasets. Balanced trees such as AVL or Red-Black trees maintain this logarithmic height through rotation operations during insertion and deletion, ensuring the O(log n) search time even after multiple modifications. Explanation of Incorrect Options: A) O(n) : This would be the time complexity for searching in an unbalanced BST or a linked list, where all nodes are skewed to one side. However, a balanced BST ensures O(log n) complexity. C) O(n2) This complexity is not applicable to BST search operations. It might appear in poorly optimized nested loops or certain pathological cases in other algorithms. D) O(1) Constant time search is achieved in hash tables, not in BSTs, as BSTs require traversing nodes to locate the target element. E) O(nlog n) This is the complexity of sorting algorithms like Merge Sort or Heap Sort, not searching in a BST.
A enters B’s house through a window. A commits ______________
Suit for recovery of possession of immovable property under section 6 of Specific Relief Act can be filed:
Under the Patents Act, 1970, what is the term of a patent granted in India from the date of filing?
In a case against Public servant he shall be exempted___________.
“The interpretation which is not in conflict with the intent of statute should be opted for”. This is the principle of
What are damages?
A prospectus shall not be a valid prospectus if it has been issued _____________
Under the Code on Social Security, 2020, the Employee Provident Fund (EPF) contributions are applicable to employees drawing a monthly wage up to:
The Supreme Court has recently delivered a judgment expounding the doctrine of "lis pendens in case of –
A proceeding for maintenance under S. 125 shall be made at: