Course: Data Structures and Algorithms
Why can't I use binary search on an array that isn't sorted?
Binary search works by comparing the target with the middle element and then discarding the half it cannot be in. That step is only valid if everything to the left of the middle is smaller and everything to the right is larger — in other words, if the array is sorted. On unsorted data the comparison tells you nothing about which half to keep, so the algorithm can walk past the value it is looking for. If you only search occasionally, a linear scan in O(n) is simpler. If you search often, sort once in O(n log n) and then each binary search costs O(log n).
Can you write me a full essay about the history of computing?
Outside course scope
That is outside what I can help with here — I answer questions about the material in Data Structures and Algorithms. If you have a question about searching, sorting, complexity or any other topic in this course, I can help with that.