Jason Orendorff
August 12, 2012
7.1k

# Sorting and searching at the library

The algorithms librarians use for sorting and searching physical books are a little different from what you learned in school. The reasons for these differences are surprising.

August 12, 2012

## Transcript

1. ### by jason orendorff for hack day, 11 august 2012 at

the library Saturday, August 11, 12

3. ### books = [ "001.4 Graphs", "001.56 Symbols", ..., "998.9 Antarctica"

] Saturday, August 11, 12

14. ### • humans are not machines • this is not the

binary search problem? Saturday, August 11, 12
15. ### • humans are not machines • this is not the

binary search problem Saturday, August 11, 12
16. ### • humans are not machines • this is not the

binary search problem • the cost model is wrong Saturday, August 11, 12
17. ### • humans are not machines • this is not the

binary search problem • the cost model is wrong • also: the library cheats Saturday, August 11, 12

21. ### how to sort cart.sort! cart.sort() (sort cart) Array.Sort(cart); Collections.Sort(cart); std::sort(cart.begin(),

cart.end()); Saturday, August 11, 12

25. ### merge sort is optimal *up to a constant factor *

Saturday, August 11, 12

30. ### merge sort • divide (in half) • sort halves Saturday,

August 11, 12
31. ### merge sort • divide (in half) • sort halves •

merge Saturday, August 11, 12
32. ### merge sort • divide (in half) • sort halves •

merge bucket sort Saturday, August 11, 12
33. ### merge sort • divide (in half) • sort halves •

merge bucket sort • divide (in bins) Saturday, August 11, 12
34. ### merge sort • divide (in half) • sort halves •

merge bucket sort • divide (in bins) • sort bins Saturday, August 11, 12
35. ### merge sort • divide (in half) • sort halves •

merge bucket sort • divide (in bins) • sort bins • merge done! Saturday, August 11, 12

11, 12