May 2017
Intermediate to advanced
310 pages
8h 5m
English
A list containing elements 60, 1, 88, 10, and 100 is an example of an unordered list. The items in the list have no order by magnitude. To perform a search operation on such a list, one proceeds from the very first item, compares that with the search item. If a match is not made the next element in the list is examined. This continues till we reach the last element in the list or until a match is made.
def search(unordered_list, term): unordered_list_size = len(unordered_list) for i in range(unordered_list_size): if term == unordered_list[i]: return i return None
The search function takes as parameters, the list that houses our data and the item that we are looking for called the search term.
The size of the ...