I am learning algorithms and I learned that binary search applies only to a sorted list of elements, but it is not written why an unsorted one cannot be used. Can you explain why?
Answer 1, authority 100%
Binary search algorithm assumes iterative division of the list in half, where at each step the desired element is compared with the value of the middle item in the sorted list. If the desired element is less than the middle element, then we will continue to search in the first half, if more, then in the second half, if equal, then we have found the desired element.
If the list is not sorted, then it is impossible to use the half division algorithm, because the element you are looking for can appear in any half of the list.