What is the time complexity of the binary search algorithm?
- O(1)
- O(log n)
- O(n log n)
- O(n)
The time complexity of the binary search algorithm is O(log n), where n is the number of elements in the sorted array. This efficiency is due to the algorithm halving the search space in each step.
Loading...
Related Quiz
- You're designing a real-time system where multiple threads must execute tasks at precise intervals. How would you ensure proper thread scheduling to meet these timing requirements?
- Explain the purpose of the ARP protocol in the TCP/IP protocol suite.
- Explain the concept of polymorphism in OOP with an example.
- Imagine you're designing a system where multiple tasks need to be executed concurrently with varying levels of urgency. How would you design a data structure to manage these tasks efficiently?
- Explain the concept of a spanning tree in graph theory and its significance in network design.