Reputation: 345
Is that possible to prove that a lower bound on the time complexity of any comparison based search algorithm for sorted lists exists? In other words, does any algorithm that takes as input a sorted list and an element and outputs the index of the element in the list (if it appears) have to take a certain number of steps?
Upvotes: 0
Views: 88
Reputation: 1154
The accepted way to do the particular algorithm you suggested is a binary search https://en.wikipedia.org/wiki/Binary_search_algorithm, which has an average time complexity of O(log N). As noted in a comment above, this algorithm and many like it can be done in a single step under perfect circumstances.
In general, proving that an algorithm is optimized is a difficult problem, which involves either classifying the algorithm or an appeal to triviality. You can find more information here:
Here:
And here:
https://www.quora.com/Is-there-any-known-way-to-prove-that-an-algorithm-is-optimal
Upvotes: 1