Jeff Cohen
August 07, 2016
200

# Computer Science: The Good Parts (2016)

Slides presented at ThatConference 2016

August 07, 2016

## Transcript

3. ### A data structure is a way to organize data. Diﬀerent

data structures exist for a reason. Data Structures Algorithms List Array Hash Tree Graph

1 9 v
5. ### Data Structures Algorithms List Array Hash Tree Graph 2 5

1 9 a a[0] a[1] a[2] a[3]

9. ### Jeff Alice Bob Amy Dave Data Structures Algorithms List Array

Hash Tree Graph
10. ### Jeff Alice Bob Amy Dave Data Structures Algorithms List Array

Hash Tree Graph
11. ### Data Structures Algorithms • Who's status updates would I like

to see? • What should I buy? • What advertisement would inﬂuence my behavior the most right now? • I'm bored. How do I get to the pool? • Our website crashed. How do we get our airplane schedule back to normal?

13. ### Jeff Alice Bob Amy Dave Data Structures Algorithms List Array

Hash Tree Graph

15. ### Select the data structure that resembles the real-life problem that

you’re trying to solve. Data Structures Algorithms
16. ### An algorithm computes a result by operating upon a data

structure. Data Structures Algorithms

19. ### An algorithm computes a result by operating upon a data

structure. The complexity of an algorithm depends upon the data structure it is forced to work with. Complexity

21. ### def search(people, name_to_find) for person in people if person.name ==

name_to_find return person end end return nil end Complexity: "Big O" Notation

23. ### def search(people, name_to_find, from = 0, to = nil) to

||= people.count - 1 mid = (from + to) / 2 if name_to_find < people[mid].name search(people, value, from, mid-1) elsif name_to_find > people[mid].name search(people, value, mid+1, to) else people[mid] end end Complexity: "Big O" Notation

O" Notation
25. ### def calculate_total(customer) total = 0 for order in customer.orders do

for item in order.line_items do total += item.price end end total end Complexity: "Big O" Notation
26. ### O(n2) def calculate_total(customer) total = 0 customer.orders.each do |order| order.line_items.each

do |item| total += item.price end end total end 0 100 200 300

30. ### Computer science is not computer programming. It’s the pursuit of

understanding how humans think and solve problems. Computational Thinking
31. ### • Break problems into small pieces. • Focus on one

thing at a time. • Follow the recipe of a proof. • Make the invisible visible. • Do the simplest thing that can possibly work. • Describe your problem out loud (rubber ducky!) • There's no problem that another level of indirection can't solve. :-)  Computational Thinking

people.
34. ### 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.
35. ### A ship in port is safe; but that is not

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

37. ### Applied Science! • Watch out for nested loops. • Know

how to use different data structures. • Solve a problem from ﬁrst principles. • Try to classify method “complexity” (Big O). • Read the source of code you use. • Learn how to benchmark your code. • Join the tradition of doing something meaningful!