Jeff Cohen
November 09, 2016
280

# (RubyConf 2016) Computer Science: The Good Parts

My keynote talk from RubyConf 2016 in Cincinnati.

## Jeff Cohen

November 09, 2016

## Transcript

Binary Tree

12. ### Complexity A "green" test suite is not an indicator of

sustainability. Some implementations are more complex than others. • Time • Space
13. ### O(n) def exists?(name_to_find, names) names.each do |name| return true if

name == name_to_find end return false end
14. ### def exists?(name_to_find, names) names.each do |name| return true if name

== name_to_find end return false end O(n) 0 100 200 300 O(n)
15. ### O(log n) def exists?(name_to_find, sorted_names)     midpoint = sorted_names.length

/ 2   return true if sorted_names[midpoint].name == name_to_find   if name < sorted_names[midpoint].name   search(name_to_find, sorted_names[0, midpoint])   else   search(name_to_find, sorted_names[midpoint, -1])   end   return false  end
16. ### def exists?(name_to_find, sorted_names)     midpoint = sorted_names.length / 2

return true if sorted_names[midpoint].name == name_to_find   if name < sorted_names[midpoint].name   search(name_to_find, sorted_names[0, midpoint])   else   search(name_to_find, sorted_names[midpoint, -1])   end   return false  end O(log n) 0 100 200 300 O(log n) O(n)

18. ### O(n2) def make_combinations(items) items.map do |item| items.map { |inner_item| [item,

inner_item] } end end [1,2,3] => [[1,1], [1,2], [1,3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]
19. ### O(n2) def make_combinations(items) items.map do |item| items.map { |inner_item| [item,

inner_item] } end end 0 100 200 300 O(n2) O(n) O(log n)

26. ### Grace Hopper Humans are allergic to change. They love to

say, "We've always done it this way." I try to ﬁght that.    That's why I have a clock on my wall that runs counter-clockwise.
27. ### Grace Hopper A ship in port is safe; but that

is not what ships are built for. Sail out to sea and do new things.