WBJECA 2025 Computer PYQ — What is the worst case time complexity to access an element in a … | Mathem Solvex | Mathem Solvex
Tip:A–D to answerE for explanationV for videoS to reveal answer
WBJECA 2025 — Computer PYQ
WBJECA | Computer | 2025
What is the worst case time complexity to access an element in a binary search tree?
Choose the correct answer:
A.
O(n)
(Correct Answer)
B.
O(n∗logn)
C.
O(1)
D.
O(logn)
Correct Answer:
O(n)
Explanation
Correct Option: (A) O(n)
Explanation
In a Binary Search Tree (BST), the time complexity of searching (or accessing) an element depends on the height of the tree.
Average Case: For a balanced binary search tree, the search takes O(logn) time, as you eliminate half of the remaining tree with each comparison.
Worst Case: The worst case occurs when the tree is "unbalanced" (specifically, when it resembles a linked list, where every node has only one child). In this scenario, the height of the tree becomes n, and you may need to traverse every single node to find the target element.
Complexityworst=O(n)
This happens because the depth of the tree d in the worst case is:
d=n
Explanation
Correct Option: (A) O(n)
Explanation
In a Binary Search Tree (BST), the time complexity of searching (or accessing) an element depends on the height of the tree.
Average Case: For a balanced binary search tree, the search takes O(logn) time, as you eliminate half of the remaining tree with each comparison.
Worst Case: The worst case occurs when the tree is "unbalanced" (specifically, when it resembles a linked list, where every node has only one child). In this scenario, the height of the tree becomes n, and you may need to traverse every single node to find the target element.
Complexityworst=O(n)
This happens because the depth of the tree d in the worst case is: