Linear Search

  • Uploaded by: Muhammad Rana Farhan
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Linear Search as PDF for free.

More details

  • Words: 73
  • Pages: 1
Linear Search #include #include int search(int a[], int k, int si){ int i=0; while(k!=a[i] && i<si ){ i++; } if(i<si) return i; else return -1; } void main() { clrscr(); const int s=5; int a[s]={3,5,1,4,2}; int key,element; cout<<"\nEnter the key: "; cin>>key; element=search(a,key,s); if(element!=-1) cout<<"\nKey found at location ["<<element<<"]" ; else cout<<"\nKey was not found"; getch(); }

Click the link below to see more examples URL: http://ravianeducation.blogspot.com E-Mail: [email protected] Farhan: 03008855006

Related Documents

Linear Search
May 2020 6
Linear Search
June 2020 7
Ex3 Linear Search
October 2019 7
Search Search
October 2019 35

More Documents from "fitriani"

Factorial
June 2020 13
Lecture 10
June 2020 19
Scientific Calculator
June 2020 8
Intermediate Part Ii
June 2020 9
Intermediate Part Ii
June 2020 6