program 1

import java.util.*;

public class MyClass {

    public static void main(String args[]) {

        Scanner in = new Scanner (;


      int n, ns, lb =0, ub =9, p=0,k=0;

      int m[] = new int [10];


      System.out.println("Enter the array");

      for (int i =0; i<10; i++){

          m[i] = in.nextInt();


      System.out.println("enter number to be searched");

      ns = in.nextInt();


      while (lb<ub){

      p = (lb+ub)/2;

      if (m[p]<ns)

      lb = p+1;

      if (m[p]>ns)

      ub = p-1;

      if (m[p] == ns){

      k =1;




      if (k==1)

      System.out.println("Search successful");








Popular posts from this blog

Imagine that you were all alone at home on a winter night. Suddenly there was thunder, lightning and heavy rain. There was no electricity, and the inverter in your house stopped working. Narrate how you felt and what you did at that time.

“Every person must have some skill in life.” Describe an important skill that you are learning, giving the various advantages that will accrue to you after learning it.

You visited a heritage site with your classmates and teachers. Describe what you saw and learned from your visit.

The Boy Who Loved

“Prayer does not change things. It changes people and people change things.” What do you think about the saying? Describe an incident from your personal experience to prove your point.

Life Update: I am on leave from school for studies

Contact Us

What type of friend would you like to have, someone who is rich, someone who is helpful or someone who is reliable? Describe which are the characteristics that are most important for you and why?

Narrate an experience that shows appearances can be deceiving

The Dark Side of AI: A Human Enemy, Not a Friend