
    public static void main(String args[]) {

        int s, mid, t, n, high, low, h;

        Scanner scan = new Scanner(System.in);

        System.out.println(" Enter the size of the search array ");

        n = scan.nextInt();

        int[] a = new int[n];
        int index1[] = new int[2];
        index1 = search(a, n);
        if (index1[0] == -1) 
        {
            System.out.println(" Element is not found ");
        } 
        else
        
        {
            System.out.println("Element found in Index : " + index1[0]);
        }
        System.out.println("count of Liner : " + index1[1]);
        // End Liner Search ^_^

        System.out.println(" Enter the size of the binary search array 2 ");
        h = scan.nextInt();
        int[] r = new int[h];
        int index2[] = new int[2];
        index2 = Binarysearch(r, h);

        if (index2[0] == -1) 
        {
            System.out.println(" Element is not found");
        } 
        else 
        {
            System.out.println("is found at position " + index2[0]);
        }
        System.out.println("count of Binary : " + index2[1]);
    }

    public static int[] search(int a[], int size) {
        int x, n = size, count = 0;
        int[] arr = new int[2];
        Scanner scan = new Scanner(System.in);

        System.out.println(" Enter " + n + " elements of the array  ");
        for (int i = 0; i < a.length; i++) {
            a[i] = scan.nextInt();
        }
        System.out.println(" Enter the search element ");
        x = scan.nextInt();
        int j = 0;
        while (j < a.length) 
        {
                         //arr[1] = count++;   قبل الشرط 
            if (x == a[j])               //       /\
            {                             //     /||\
                arr[0] = j;              //     /||||\
                arr[1] = count++;      //      /||||||\
                return arr;             //       ||||
            }                            //       ||
             arr[1] = count++;  // في الحقيقة لا أعلم هل الموضع الصحيح للكاونتر هنا أم قبل الشرط 
            j++;
        }
        arr[0] = - 1;
        return arr;
    }

    public static int[] Binarysearch(int r[], int size) {
        Scanner scan = new Scanner(System.in);
        int mid, t, n, high, h = size, low, s, count = 0;
        int[] arr = new int[2];
        System.out.println(" Enter  " + h + " number  in ascending order ");
        for (t = 0; t < r.length; t++) {
            r[t] = scan.nextInt();
        }
        System.out.println(" Enter the search element 2 ");
        s = scan.nextInt();
        low = 0;
        high = h - 1;
        while (low <= high) {
            mid = (low + high) / 2;
            if (s == r[mid]) {
                arr[1] = count++;     // countr
                arr[0] = mid;
                return arr;
            }
            if (s < r[mid]) {
                count++;      // countr
                high = mid - 1;
            } else {
                count++;        // countr
                low = mid + 1;
            }

        }

        arr[0] = - 1;
        return arr;
    }