HackToHell. Powered by Blogger.

Binary Search using functions

class bin{
public void fg(int a[],int y){
int f=0,l=a.length-1;
int mid=0;
while(f<=l){
mid=(f+l)/2;
if(m[mid] <s)
f=mid+1;
if(m[mid]>s)
l=mid-1;
if(m[mid] == s){
k=1;
break;
}
}
if( k == 1)
System.out.println("Found");
else
System.out.println("Not Found");
}
public static void main(String args[]){
int a[]={1,2,3,4,5,6,7,8,9,10};
bin j = new bin();
j.fg(a,6);
}
}

 

As usual compile as javac bin.java

run as java bin

Share on Google Plus

About hacktohell

Love technology.
    Blogger Comment
    Facebook Comment

1 comments:


  1. In today's digital age, sharing links has become a common practice, often involving URL shortening services like t.co/Ye9FIjHQ5p. These shortened links help make URLs more manageable and easier to include in social media posts. However, users should always verify the destination to ensure safety and authenticity. Being cautious with shortened links can prevent potential security issues and enhance online trust.

    ReplyDelete