In a binary search algorithm, what is the time complexity for searching an element in a sorted array of n elements?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The time complexity of a binary search algorithm is O(log n), as it repeatedly divides the search interval in half, resulting in a logarithmic time complexity. This makes it more efficient than linear search algorithms (O(n)).
Loading...
Related Quiz
- What is the primary goal of data mining in a business context?
- In time series analysis, _______ is a common method used to smooth out short-term fluctuations and highlight longer-term trends or cycles.
- For a software development team, which KPI would be most appropriate to measure the success rate of product releases?
- When designing a dashboard for an educational institution, what features should be included to track student performance and engagement effectively?
- In SQL, what statement is used to add a new record to a table?