24 September 2021

Algorithms

Reading is posted on Canvas.

An algorithm is recipe for performing a procedure. Algorithms, to be practical, must exhibit these characteristics.

Searching A List You can search a list for an item by iterating through the list, and reporting you found it if you find it, and by reporting it's not there if you get to the end of the list without finding it. The time it takes to do this is at worst proportional to the length of the list. We say this algorithm is \(O(n)\).

Binary Search This is a means of searching for an item in a sorted list. I am going to describe this algorithm and you are going to use it to write a program that searches a scrabble dictionary for a word that is specified as argv[1]. You may hard-code the filename scrabble.txt in your prgram. Here is the idea.

Each iteration cuts the size of the search field in half. It is not hard to see that, given a number \(n\), if divide it by 2 \(\lceil \log_2(n)\rceil\) times, that it will be reduced to 1 or 0. This algorithm terminates after that many iterations. Hence, this is a \(O(\log(n))\) time algorithm. Doubling the size of the list only increases the work by one iteration.

Pairings These were assigned randomly by the program mateFools.py.

Block B
Partner IPartner II
deng22jwang22l
wild22rsingh22c
dai23sdoki22a
sowers22jvazquez22t
frisard23kvanfleet22m
tsuboyama23swin22k
villalpando22bsharma22s
miller22johnagrella23c
etin22aokkonkwo22d
pagar23achatta22s

Block F
Partner IPartner II
warren22bluftig22n
liu22hongfetkovich23j
prakki23sworkukebede22m
kandula23sshaffer22c
warner22aliu23e
huo22jkrasinski23r
chen23erickarty22j
zheng23imahadeshwar23i
khaire23alee23m
narala23ppatel23prantham