Lets say,
I have 1000 elements in a array and I want to search 10 elements in that array,then which searching mechanism is most appropriate?
Also , if in case , I need to search 900 elements from the same array,then what search method is good one?
Linear or Binary search ?
Thanks in advance.
If the elements aren't sorted, then you can't do a binary search. But binary search is so much faster than linear search (you'd need to look at an average of 10 elements rather than 500) that you'd be best sorting your list (using an algorithm such as quicksort) and then doing a binary search.