CSC 2200 Lecture Notes - Lecture 18: Linear Search, Search Algorithm
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