Yes, great analysis!
It is O(n) because you searched in an array, not in a balanced binary tree and because you used the wrong searching algorithm.
To get the time you want you have to use a O(logn) sort algorithm such as qsort to sort the array and then use binary search to find a value.





Reply With Quote
Bookmarks