Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

http://imgs.xkcd.com/comics/the_general_problem.png

Slide 4

Slide 4 text

The Good Parts Data Structures Algorithms Complexity Classification Computational Thinking Culture of Innovation

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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]

Slide 11

Slide 11 text

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]

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

Data Structures and Algorithms Select the data structure that resembles the real-life problem that you’re trying to solve.

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Data Structures and Algorithms An algorithm computes a result by operating upon a data structure. Charles Babbage Ada Lovelace

Slide 18

Slide 18 text

Data Structures and Algorithms

Slide 19

Slide 19 text

Margaret Hamilton Source code of the Apollo Guidance Computer

Slide 20

Slide 20 text

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.

Slide 21

Slide 21 text

Big “O” Notation O( ) O(n) O(log n) O(n^2)

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

O(n) def @people end 0 100 200 300

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

O(log n) def to mid search(@people, value, from, mid search(@people, value, mid @people end 0 100 200 300

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

O(n2) def total customer order total total end 0 100 200 300

Slide 28

Slide 28 text

http://blog.atom.io/

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Alan Turing

Slide 31

Slide 31 text

Computational Thinking Computer science is not computer programming. It’s the pursuit of understanding how humans think and solve problems.

Slide 32

Slide 32 text

Stand on Shoulders

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

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