New Member FAQ
|
Forums
|
Earn Revenue
Resources
Entrance
Ask Experts
Exam Papers
Jobs
English
Projects
Universities
Colleges
Courses
Schools
Training
My India
Members
|
Communities
|
Business Directory
|
Classifieds
|
Reviews
|
Silverlight Games
|
Peer Appraisal
|
Bookmarks
|
Polls
|
Mentors
|
Links
|
MCA Projects
|
Lobby
|
Gift Shop
|
Chat
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
PROSENJIT MANN...
(482)
Mr. Anindya
(441)
Pawan Bahuguna
(312)
Last 7 Days
Shobha Manasa
(1636)
Aira
(1481)
N K Ravishanka...
(1243)
more...
Awards & Gifts
Online Exams
Aptitude Questions
General Aptitude Tests
Medical Entrance
Engineering Entrance
Bank Tests
TOEFL & IELTS Questions
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.
Resources
»
Articles/Knowledge Sharing
»
Education
»
Program for implementation of SEARCHING TECHNIQUES
Posted Date: 17 Dec 2007
Resource Type:
Articles/Knowledge Sharing
Category:
Education
Author:
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
Sign In
to add 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
!
More Resources
aptitude questions with answers
" Operating sytem "important questions
Syllabus for Academic Year 2007-2008 for B.Tech./MBA/MCA/B.Pharmacy.
Program for implementation of MULTI STACK
Program for implementation of DEPTH FIRST SEARCH
Program for implementation of AVL TREES
Advertise Here
Watch TV Channels
Watch Asianet online
Kairali TV in Internet
Surya TV online
Amritha TV Channel
Contact Us
Advertise
Editors
Privacy Policy
Terms Of Use
ISC Technologies.
2006 - 2009 All Rights Reserved.