Incognitozx / DSA-with-Java

Add DSA solutions in Java Programming Language.
0 stars 4 forks source link

Add Binary Search Code Using Java #1

Open Incognitozx opened 5 days ago

Incognitozx commented 5 days ago

Binary Search is a highly efficient algorithm for finding an element in a sorted array. It works by repeatedly dividing the search interval in half. If the value of the target element is less than the middle element of the array, the search continues in the left half, otherwise, it continues in the right half. This process continues until the element is found or the interval is empty.

Time Complexity: O(log n) Space Complexity: O(1) (iterative version) or O(log n) (recursive version)

princyballabh commented 5 days ago

@Incognitozx I have added the code and made a PR. Do check it out please.