What is the prerequisite for binary searching
Prerequisite for binary searching is the array should be sorted Otherwise binary searching will not work fine.
If we apply binary searching in unsorted array then it can give correct answer by mistake.
For example:
If array is 1, 2, 4, 6, 8, 9, then binary search will work fine.
If array is 4, 1, 8, 3, 9, 1 then binary search will not work
Answer by mistake: If array is 3, 10, 12, 8, 3, 20, 13. and we are searching for 8 then it will give ans 8 by mistake.
If we apply binary searching in unsorted array then it can give correct answer by mistake.
For example:
If array is 1, 2, 4, 6, 8, 9, then binary search will work fine.
If array is 4, 1, 8, 3, 9, 1 then binary search will not work
Answer by mistake: If array is 3, 10, 12, 8, 3, 20, 13. and we are searching for 8 then it will give ans 8 by mistake.