Junior
Implementation of binary search in a sorted array
livecode
Task condition
Given a sorted array of integers and a target value. Requirements:
- Implement binary search (an algorithm that divides the array in half and recursively searches for the element).
- Return the index of the element if found, or -1 if not present.
public class Main{
public static void main(String[] args) {
int arr[] = {1, 3, 5, 6, 8, 12};
}
}