Time complexity of binary search for an unsorted array
问题 I am stuck up with two time complexities. To do a binary search with sorted array is O(logN). So to search an unsorted array we have to sort it first so that becomes O(NlogN). So then we can perform binary search which gives the complexity as O(N) but I have read that it could be O(NlogN). Which is correct? 回答1: Binary Search is for "Sorted" lists. The complexity is O(logn). Binary Search does not work for "un-Sorted" lists. For these lists just do a straight search starting from the first