Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Computer Science: The Good Parts (2016)

Computer Science: The Good Parts (2016)

Slides presented at ThatConference 2016

Jeff Cohen

August 07, 2016
Tweet

More Decks by Jeff Cohen

Other Decks in Programming

Transcript

  1. A data structure is a way to organize data. Different

    data structures exist for a reason. Data Structures Algorithms List Array Hash Tree Graph
  2. Data Structures Algorithms • Who's status updates would I like

    to see? • What should I buy? • What advertisement would influence 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?
  3. Select the data structure that resembles the real-life problem that

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

    structure. Data Structures Algorithms
  5. 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
  6. 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
  7. 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
  8. 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
  9. Computer science is not computer programming. It’s the pursuit of

    understanding how humans think and solve problems. Computational Thinking
  10. • 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
  11. Humans are allergic to change. They love to say, "We've

    always done it this way." I try to fight that.
 
 That's why I have a clock on my wall that runs counter- clockwise.
  12. A ship in port is safe; but that is not

    what ships are built for. Sail out to sea and do new things.
  13. Applied Science! • Watch out for nested loops. • Know

    how to use different data structures. • Solve a problem from first 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!