Algorithms and Data
Structures
The Real Life Version
in Ruby
mostly...
Monday, May 12, 14
Slide 2
Slide 2 text
Thanks Abril Pro Ruby!
A Conference on a beach...
In Brazil...
YOU ARE AWESOME!!!
Monday, May 12, 14
Slide 3
Slide 3 text
Who Am I?
I’m not Nell Shamrell!
Monday, May 12, 14
Slide 4
Slide 4 text
What is this talk about?
ask Nell ;)
Monday, May 12, 14
Slide 5
Slide 5 text
A Talk About
Algorithms
In Ruby
And how that effects our
apps...
Monday, May 12, 14
Slide 6
Slide 6 text
Algo “Rhythms” in Ruby
We all need more Rhythms in our
Algorithms!
Monday, May 12, 14
Slide 7
Slide 7 text
Ok Seriously
What is this about?
Monday, May 12, 14
Slide 8
Slide 8 text
First A Story...
Monday, May 12, 14
Slide 9
Slide 9 text
A Degree in Computer
Science
What knowledge are others missing?
What do we take for granted?
Back to Nell and I....
Monday, May 12, 14
Slide 10
Slide 10 text
Algorithm:
noun - a dirty word?
Monday, May 12, 14
Slide 11
Slide 11 text
Algorithm
noun - a step-by-step procedure for
calculations. Algorithms are used for
calculation, data processing, and
automated reasoning.
IMPLEMENTATION
!
Monday, May 12, 14
Slide 12
Slide 12 text
Types, Blah, Blah, Blah
Greedy
deterministic / non-
deterministic
Brute force
Divide and conquer
Decrease and conquer
Dynamic
programming
Transform and
conquer
Backtracking
algorithm
Monday, May 12, 14
Slide 13
Slide 13 text
We write them everyday
How we solve the problem
steps, heuristics, use of tools and
patterns
Every line of code you write is part of a
new algorithm you are creating to solve
that problem.
Monday, May 12, 14
Slide 14
Slide 14 text
Every line of code you write is part of a new
algorithm you are creating to solve that problem.
Monday, May 12, 14
Slide 15
Slide 15 text
Algorithms and data structures are
fun!!
Problem solving
how to do it
how others do it
how to do it differently again, and
again!
Fun!!
Monday, May 12, 14
Slide 16
Slide 16 text
Answering the Wrong
Question
Is there still a difference between clean
code and performant code?
Monday, May 12, 14
Slide 17
Slide 17 text
Is There?
Ah finally a thesis!
This is something that effects us all
everyday
How as Rubyists do we solve this?
Monday, May 12, 14
Slide 18
Slide 18 text
A Problem
Tic-Tac-Toe
Small well defined problem (a little
larger than a kata)
Can be very messy, and very clean :)
Monday, May 12, 14
Slide 19
Slide 19 text
A Problem
Tic-Tac-Toe
Small well defined problem (a little
larger than a kata)
Can be very messy, and very clean :)
Monday, May 12, 14
Slide 20
Slide 20 text
Borrowed From The Grand
Masters of Ruby SOLID
The Gilded Rose Kata
The Beer Song Kata
The Fizz Buzz Kata
Monday, May 12, 14
Slide 21
Slide 21 text
Null Hypothesis
There is no statistical difference in the
run-time of clean SOLID code and
messy if-else-death code
Monday, May 12, 14
Results
Statistically Significant?
Yes
How much should we care?
It Depends... :)
Monday, May 12, 14
Slide 28
Slide 28 text
Built-In choices
Searching and
Sorting
Enumerable
each
while
Data structures
generic types -
RBasic or just
VALUE
Custom objects -
RObject
GC ...
Monday, May 12, 14
Slide 29
Slide 29 text
What it all means
Donald Knuth
The Art of Computer Programming
The Aesthetics of our Code
"I'll show you can't prove
that a program is
'elegant'" -
How do we define aesthetics??
Time?
Maintainability?
Small?
Simple?
Readability? Gregory
Chaitin
Completeness?
Slide 42
Monday, May 12, 14
Slide 30
Slide 30 text
Reading List!
Practical
Less Practical
Monday, May 12, 14