Jeff Cohen
September 17, 2015
180

# 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

## Transcript

3. ### The Good Parts Data Structures Algorithms Complexity Classiﬁcation Computational Thinking

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

to organize data. Diﬀerent data structures exist for a reason.
5. ### Data Structures and Algorithms A data structure is a way

to organize data. Diﬀerent data structures exist for a reason. List Array Hash Tree Graph
6. ### Data Structures and Algorithms A data structure is a way

to organize data. Diﬀerent 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. Diﬀerent data structures exist for a reason. List Array Hash Tree Graph a
8. ### Data Structures and Algorithms A data structure is a way

to organize data. Diﬀerent 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. Diﬀerent data structures exist for a reason. List Array Hash Tree Graph a a[0] a[1] a[2] a[3]
10. ### Data Structures and Algorithms A data structure is a way

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

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

Alice Bob Amy Dave
13. ### Data Structures and Algorithms Select the data structure that resembles

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

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

operating upon a data structure. Charles Babbage Ada Lovelace

18. ### 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.

20. ### 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

22. ### 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
23. ### O(log n) def to mid search(@people, value, from, mid search(@people,

value, mid @people end 0 100 200 300
24. ### 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

200 300

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

pursuit of understanding how humans think and solve problems.

30. ### Applied Science! ★ Watch out for loops ★ Watch out

for nested loops ★ Learn every kind of Ruby data structure ★ Solve a tiny problem from ﬁrst 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 Gemﬁle. ★ Learn how to use the Benchmark class ★ Join the tradition of accomplishing something meaningful