From 67c496bd165e243da346666cb11537fd6f84ca74 Mon Sep 17 00:00:00 2001 From: Swati Srivastava <67548404+SwatiSrivastava216@users.noreply.github.com> Date: Sun, 9 Oct 2022 17:13:23 +0530 Subject: [PATCH] Add files via upload --- .../Order_Agnostic_Binary_Search.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 binary-search/Order_Agnostic_Binary_Search.java diff --git a/binary-search/Order_Agnostic_Binary_Search.java b/binary-search/Order_Agnostic_Binary_Search.java new file mode 100644 index 0000000..16c97ab --- /dev/null +++ b/binary-search/Order_Agnostic_Binary_Search.java @@ -0,0 +1,37 @@ +// Contributed By: Swati Srivastava (https://github.com/SwatiSrivastava216) +import java.util.Scanner; +public class Main { + static int bsearch(int arr[],int key){ + int start=0; + int end=arr.length-1; + boolean isasscending; + if(arr[start] arr[mid]) + end=mid-1; + else + start=mid+1; + } + } + return -1; + } + public static void main(String[] args){ + int[] arr={1926,2756,3581,4386,5145}; + int key=4386; + System.out.println(bsearch(arr,key)); + } +}