Page 1 of 1

IN JAVA (CodeZinger) Binary Search Given a sorted array A and an element to search E, find the index of the element usin

Posted: Mon Jul 11, 2022 9:55 am
by answerhappygod
IN JAVA (CodeZinger)
Binary Search
Given a sorted array A and an elementto search E, find the index ofthe element using the binary search algorithm. If theelement is not found in the array return -1.
Reference: http://www.algolist.net/Algorithms/Binary_search
Input: 10 2 4 5 6 8 12 15 18 30 54 8
where,
Output: 4
The given array contains the element 8 at index 4 (index startsfrom 0).