Tuesday, 14 March 2017

Implement Binary Search using recursion in C Language

#include<stdio.h>
#include<conio.h>
int binary(int a[],int beg,int last,ele);//function binary serach

void main()
{
 int a[20],ele,n,beg,last,i;
clrscr();

printf("ENTER THE SIZE OF YOUR ARRAY MAX-20\n);
scnaf("%d',&n); //Size from user

printf("ENTER THE ELEMENTS OF YOUR ARRAY\n"):
for(i=0;i<n;i++)
{
 scanf(%d",&a[i]); //Insertion of elements
}

printf("ENTER THE ELEMENT TO SEARCH\n");
scanf("%d",ele); //Element for search

beg=0,last=n-1; //setting location of beginning and last
m=binary(a,beg,last,ele);
if(m==-1)
{
  printf("ELEMENT NOT FOUND\n");
}
else
printf("ELEMENT FOUND AT LOCATION: %d\n",m+1);//printing the location
getch();

}
void binary(int a[],int beg,int last,ele) //Definition of binary function
{
 int mid,c=-1;

if(beg<=last)
{
 mid=(beg+last)/2;
 if(ele==a[mid])
{
    c=mid;
    if(ele>a[mid])
     {
          return binary(a,mid+1,last,ele);
}
else
return binary(a,beg,mid-1,ele);
 }
  return c;
}
     

Thursday, 8 December 2016

Surf the world.

ONLINE WORLD AND  ITS CURVES:


VISIT THE BELOW GIVEN LINKS AND LOOK AROUND A WHOLE NEW  NET-WORLD.
SEARCH  AND  EXPLORE.


1.A Light Year.


2.The  Internet Eye.

3.Online Candy Catch.

4.The Kawai Runner.

5.How Old Are You in Some other World.

6.Loop YouTube Videos.(Slow Site)

7.Google Gravity.

8.The Pee Man.

9.Avoid Humans.

10.The Old Maps.

11.The Gravity.

12.The Particle Player.

Disclaimer:

I Do Not Own Any Of These Site.
Visit On Your Own Discretion.
Just For Fun.