Searching: look for item in collection

Searching: look for item in collection
Boolean: is it there or not? t/f
Position searches: index number or -1 for
failure if static data structure, if dynamic,
address and NULL if fails
Record search: search on unique key and return
back all information, failure depends on static
or dynamic -1 or NULL
Sequential and binary
Generally, look until find or out of data
Sequential: Unsorted data, slow if a long list
set start to 0
set found to false
while not off end (< N) and haven’t found
if current item equals item
go to next
end while
O-notation: categorization of algorithm
complexity: look at average case
Use avg case, disregard coefficients and +/O(...): indicates something about N
O(1): constant: on the order of one calculation
finding maximum in a heap
O(log2N): logarithmic: binary search
O(N): linear: sequential search
O(Nlog2N): better sorts: merge, quick, shell
O(N2): worse sorts: bubble, selection, insertion
Binary search: Must be sorted, very fast
2 base cases: not found or found
2 recursive cases: search lower, search upper
Parameters which change: