Searching: Ref.: D.S. Malik, Data Structures Using C++
Searching: Ref.: D.S. Malik, Data Structures Using C++
Searching
n size of the list f(n) the number of comparisons done by the search algorithm
Array-Based Lists
[0] [1] [2] [3] [4] [5] [6] [7] list 35 12 27 18 45 16 38
search for 27
compare 27 with list[0] compare 27 with list[1] compare 27 with list[2] X X
Array-Based Lists
search for 10
compare 10 with list[0] X keep going until there is no more data
struct nodeType { Type info; nodeType <Type> *next; nodeType <Type> *back; };