CP164 Lecture Notes - Lecture 9: Linear Search, Binary Search Algorithm, Data Element
Document Summary
Write own search method by comparing (def _eq_) Can only compare food objects with other food objects (not strings) On have _first because there is no priority. Implementation: ex. if key_movie is in movie: (def_contains_ then python will know how to use in) define in the queue class. Add deepcopy to the value to not make a direct reference. Write own search to later in course do a binary search. For loop only stops when we hit end. But with while loop you can stop when condition is met. Searches for the first occurrence of key in the list. Private helper method - used only by other adt methods. Key - a partial data element (?) I - the index of key in the list, -1 if key is not found (int) #make loop as small as we can ( don"t put ifs inside body of loop) Linear search method is a private helper method.