CSC 2200 Lecture Notes - Lecture 18: Linear Search, Search Algorithm

11 views3 pages
CSC 2200 lecture 18
Linear search
oVery simple search algorithm
oIn this type of search, a sequential search is made over all items one by one
oEvery item is checked and if a match is found then that particular item is
returned, otherwise the search continues till the end of the data collection
oPseudo code
Procedure linearSearch(list,value){
For each item in the list
If match item ==value
Return item’s location
End if
End for
End procedure
}
Linear search algorithm
1. Set I to 1
2. If i>n then go to step 7
3. If a[i]=x then go to step 6
4. Set i to i=1
5. Go to step 2
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents