What is the time complexity of searching for an element in a binary search tree (BST)?
- O(1)
- O(log n)
- O(n log n)
- O(n)
The time complexity of searching for an element in a binary search tree (BST) is O(log n), where n is the number of nodes in the tree. This is because in a balanced BST, each comparison made during the search reduces the search space by half, leading to logarithmic time complexity.
Loading...
Related Quiz
- To eliminate transitive dependency, a relation must be in at least ___________ Normal Form (NF).
- In a real-time embedded system, memory management is critical for ensuring timely response to external events. How would you design a memory management scheme to meet real-time constraints?
- _________ is a Git command used to rewrite commit history.
- Advantages and disadvantages of using threads vs. processes
- In OSPF (Open Shortest Path First) routing protocol, LSAs (Link State Advertisements) are flooded within a ___________.