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

Algorithms Complexity - A brief analisys on com...

Algorithms Complexity - A brief analisys on computational cost

Once upon a time where computer scientists worries about computational resources limitation. They needed to work on the available hardware that wasn't that fast compared to nowadays. This presentation is about how we can back to the golden age of developers where performance wasn't optimized by buying expensive hardwares.

Emanuel de Souza

June 11, 2016
Tweet

More Decks by Emanuel de Souza

Other Decks in Programming

Transcript

  1. Numbers and Facts 31 years old++ (and counting)
 22 years

    programming++ (first code at 9 years old)
 13 years professional exp++ (nonstop coder)
 2 daughters (not planning incrementing this counter)
 1 wife (neither this one)
 
 CTO at Contentools Inc
 Python evangelist
 PyBr Member
 Simplicity lover
 Open source contributor
  2. Algorithm Complexity • Two dimensions (time and space) • Time

    = CPU • Space = Memory • Classified using Big-O Notation
  3. Given a number “x" calculate the result of sum of

    terms from “1" given 1 < x.
 e.g: 1 + 2 + 3 + … + 10 =
  4. The naive O(nˆ2) solution For each value from 1 to

    x, implements a counter to be increased CHECK THE CODE AT
 http://github.com/emanuelcds/complexity
  5. The fair O(n) solution For each value from 1 to

    x, increase the result by the current iterator value CHECK THE CODE AT
 http://github.com/emanuelcds/complexity
  6. The optimized O(1) solution Writing the sequence 1, 2, …,

    n and repeat the same sequence on inverted order underneath each other CHECK THE CODE AT
 http://github.com/emanuelcds/complexity If you just sum each column, you will have the same result So, we can easily deduce a single equation for the result, obtaining a O(1) observation