* Binary search only
works when our list
is sorted
Slide 27
Slide 27 text
Searching for a new
place to live…
Optimal stopping
Slide 28
Slide 28 text
or finding a significant
other
Slide 29
Slide 29 text
The secretary problem
Slide 30
Slide 30 text
https://giphy.com/gifs/scooby-doo-wfOe7SdZ3XyHm
Slide 31
Slide 31 text
http://gph.is/15twRiZ
Slide 32
Slide 32 text
37%
Slide 33
Slide 33 text
* When we don’t
know all the options,
optimal stopping
tells us when to stop
and make a decision
Slide 34
Slide 34 text
Digging at grandma’s
attic
Recursion
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
box
box
container box
Slide 37
Slide 37 text
Make a pile
of boxes
while the pile
is not empty
Grab
a box
if you find a box,
add it to the
pile of boxes
Go back to
the pile
if you find
a diary,
you’re done!
Slide 38
Slide 38 text
Go through
each item in the box
if you find a box…
if you find a diary,
you’re done!
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
def factorial(x)
if x == 1
1
else
x * factorial(x-1)
end
end
Slide 41
Slide 41 text
def factorial(x)
if x == 1
1
else
x * factorial(x-1)
end
end
Slide 42
Slide 42 text
def factorial(x)
if x == 1
1
else
x * factorial(x-1)
end
end
Client 1: 4 days task
Client 2: 1 day task
= 5 days of work
Slide 67
Slide 67 text
Client 1: 4 days task = 4 days waiting
Client 2: 1 day task = 5 days waiting
= 9 days of waiting
Slide 68
Slide 68 text
Client 2: 1 day task = 1 days waiting
Client 1: 4 days task = 5 days waiting
= 6 days of waiting
Slide 69
Slide 69 text
Shortest processing time
Client 2: 1 day task = 1 days waiting
Client 1: 4 days task = 5 days waiting
= 6 days of waiting
Metric: sum of completion times
Slide 70
Slide 70 text
Suppose we want to
find a magician
Breadth first search