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

Computer Science: The Good Parts

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.

Jeff Cohen

September 17, 2015
Tweet

More Decks by Jeff Cohen

Other Decks in Programming

Transcript

  1. Data Structures and Algorithms A data structure is a way

    to organize data. Different data structures exist for a reason.
  2. 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
  3. 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
  4. 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
  5. 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
  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 a a[0] a[1] a[2] a[3]
  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 :name => “Jeff” :id => 2 …. :email => “j@..” params[:id]
  8. Data Structures and Algorithms Select the data structure that resembles

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

    operating upon a data structure. Charles Babbage Ada Lovelace
  10. 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.
  11. 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
  12. 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
  13. Computational Thinking Computer science is not computer programming. It’s the

    pursuit of understanding how humans think and solve problems.
  14. 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