Computer Science: The Good Parts

8217faf2bfdfa7daf10135d41ddd421e?s=47 Jeff Cohen
September 17, 2015

Computer Science: The Good Parts

For those of us without a computer science background, here are just a few things that can elevate your thinking and programming skills. Presented at WindyCityRails 2015.

8217faf2bfdfa7daf10135d41ddd421e?s=128

Jeff Cohen

September 17, 2015
Tweet

Transcript

  1. Computer Science: The Good Parts @jeffcohen Jeffrey Cohen csthegoodparts.com

  2. None
  3. http://imgs.xkcd.com/comics/the_general_problem.png

  4. The Good Parts Data Structures Algorithms Complexity Classification Computational Thinking

    Culture of Innovation
  5. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason.
  6. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph
  7. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph
  8. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph a
  9. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph a
  10. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph a a[0] a[1] a[2] a[3]
  11. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason. List Array Hash Tree Graph :name => “Jeff” :id => 2 …. :email => “j@..” params[:id]
  12. Data Structures and Algorithms List Array Hash Tree Graph Jeff

    Alice Bob Amy Dave
  13. Data Structures and Algorithms List Array Hash Tree Graph Jeff

    Alice Bob Amy Dave
  14. None
  15. Data Structures and Algorithms Select the data structure that resembles

    the real-life problem that you’re trying to solve.
  16. Data Structures and Algorithms An algorithm computes a result by

    operating upon a data structure.
  17. Data Structures and Algorithms An algorithm computes a result by

    operating upon a data structure. Charles Babbage Ada Lovelace
  18. Data Structures and Algorithms

  19. Margaret Hamilton Source code of the Apollo Guidance Computer

  20. An algorithm computes a result by operating upon a data

    structure. Data Structures and Algorithms The complexity of an algorithm depends upon the data structure it is forced to work with.
  21. Big “O” Notation O( ) O(n) O(log n) O(n^2)

  22. Big “O” Notation def search(name_to_find) @people.each do |person| if person.name

    == name_to_find return person end end return nil end
  23. O(n) def @people end 0 100 200 300

  24. Big “O” Notation def search(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
  25. O(log n) def to mid search(@people, value, from, mid search(@people,

    value, mid @people end 0 100 200 300
  26. Big “O” Notation def calculate_total(customer) total = 0 customer.orders.each do

    |order| order.line_items.each do |item| total += item.price end end total end
  27. O(n2) def total customer order total total end 0 100

    200 300
  28. http://blog.atom.io/

  29. None
  30. Alan Turing

  31. Computational Thinking Computer science is not computer programming. It’s the

    pursuit of understanding how humans think and solve problems.
  32. Stand on Shoulders

  33. Applied Science! ★ Watch out for loops ★ Watch out

    for nested loops ★ Learn every kind of Ruby data structure ★ Solve a tiny problem from first principles, without a database nor any gems: just the Ruby standard library. ★ Try to classify the “complexity” of your code. ★ Read the code inside every gem in your Gemfile. ★ Learn how to use the Benchmark class ★ Join the tradition of accomplishing something meaningful
  34. Computer Science: The Good Parts @jeffcohen Jeffrey Cohen csthegoodparts.com