Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Funny Photos B.Tech Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter




Program for implementation of SEARCHING TECHNIQUES


Posted Date: 17 Dec 2007    Resource Type: Articles/Knowledge Sharing    Category: Education

Posted By: Jagadeesan. D       Member Level: Silver
Rating:     Points: 4



SEARCHING TECHNIQUES

#include
#include
#include
class search{
private:
int a[20];
int i,j,temp,s,n;
public:
void getdata();
void sort();
void b_search();
void l_search();
};
void search::getdata(){
cout<<"\nEnter the Total no. of Elements\t";
cin>>n;
for(i=0;i cin>>a[i];
}
}
void search::l_search(){
cout<<"\n\n\t\t LINEAR SEARCH\n";
cout<<"\n\nEnter the Element you want to Search\t";
cin>>s;
int flag=0;
for(i=0;i if(a[i]==s) {
cout<<"\nSuccessful Search located at the position\t"<< i+1<<"\n";
flag=1;
}
}
if(flag==0)
cout<<"\n Unsuccessful Search";
}
void search::sort(){
for(i=0;i for(j=0;j if(a[i] temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
cout<<"\n\n\t\t SORTING\n";
cout<<"\n\nThe Sorted Elements are\t";
for(i=0;i cout<<"\t"< }
}
void search::b_search(){
int low,high,middle;
low=0;
high=n;
cout<<"\n\n\t\t BINARY SEARCH\n";
cout<<"\n\nEnter the Element you want to Search\t";
cin>>s;
while(low<=high) {
middle=(low+high)/2;
if(s high=middle-1;
else
if(s>a[middle])
low=middle+1;
else {
cout<<"\nSuccessfull Search located at the position \t"<< middle+1<<"\n";
return;
}
}
cout<<"\nUnsuccessful Search";
}
void main()
{
int choice;
search sh;
clrscr();
do {
cout<<"\n\t1.Linear Search";
cout<<"\n\t2.Bineary Search";
cout<<"\n\t3.Exit\n";
cout<<"\n\nInput the Choice\t";
cin>>choice;
switch(choice) {
case 1:
sh.getdata();
sh.l_search();
break;
case 2:
sh.getdata();
sh.sort();
sh.b_search();
break;
case 3:
return;
} }
while(choice<=2);
getch();
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Program for implementation of SORTING TECHNIQUES
Previous Resource: MCS601 - COMPUTER ARCHITECTURE
Return to Discussion Resource Index
Post New Resource
Category: Education


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Editors    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.