Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Algorithms & Complexity
Search
Cheesecake Labs
April 05, 2018
Programming
0
40
Algorithms & Complexity
Frank Kair
Cheesecake Labs
April 05, 2018
Tweet
Share
More Decks by Cheesecake Labs
See All by Cheesecake Labs
Cats' wellness & care
cheesecakelabs
0
58
How do we create the first impressions?
cheesecakelabs
0
67
Menstrual cup: suit and freedom
cheesecakelabs
0
82
Life is a cycle, better with a bicycle
cheesecakelabs
0
68
Interview Process: how to get the best of people
cheesecakelabs
1
100
My capsule wardrobe experience
cheesecakelabs
3
76
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
55
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
55
MBTI - Psychological types described by Jung
cheesecakelabs
0
150
Other Decks in Programming
See All in Programming
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
200
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
2.3k
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
420
AWS Infrastructure as Code の新機能 2025 総まとめ 〜SA 4人による怒涛のデモ祭り〜
konokenj
10
3.4k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
500
守る「だけ」の優しいEMを抜けて、 事業とチームを両方見る視点を身につけた話
maroon8021
3
930
AI駆動開発の本音 〜Claude Code並列開発で見えたエンジニアの新しい役割〜
hisuzuya
4
510
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
240
クライアントワークでSREをするということ。あるいは事業会社におけるSREと同じこと・違うこと
nnaka2992
1
340
Unity6.3 AudioUpdate
cova8bitdots
0
130
AI 開発合宿を通して得た学び
niftycorp
PRO
0
120
技術検証結果の整理と解析をAIに任せよう!
keisukeikeda
0
120
Featured
See All Featured
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
150
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
320
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
220
Joys of Absence: A Defence of Solitary Play
codingconduct
1
310
30 Presentation Tips
portentint
PRO
1
250
Scaling GitHub
holman
464
140k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
480
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
150
Ruling the World: When Life Gets Gamed
codingconduct
0
170
Writing Fast Ruby
sferik
630
63k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
140
Transcript
Algorithms & Complexity Frank Kair
Last time...
Project Euler
polyglot-euler
polyglot-euler
polyglot-euler
Fibonacci example
Analysis of Algorithms Asymptotics / Complexity Theory
None
Applied Maths → Computer Science
Complexity Analysis We need a way to define the runtime
of an algorithm regardless of the machine it’s currently running on.
Linear Search
Binary Search
Big O Big O is a mathematical notation that describes
the limiting behaviour of a function when the argument tends towards a particular value or infinity.
The letter O is used because the growth rate of
a function is also referred to as the order of the function. [...] an upper bound on the growth rate of the function. Big O
Big O
Big O Length Iteration worst case 1 1 10 10
100 100 1000 1000 10000 10000 … ...
Big O
None
Big O
How do we profile these algorithms?
Just count the loops, then?
Merge Sort
Merge Sort
Merge Sort
Merge Sort O(n)
Merge Sort
Merge Sort O(n)
Merge Sort O(n) O(n)
Merge Sort O(n) O(n) ?
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n T(n) = 2T(n/2) + n
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n T(n) = 2T(n/2) + n = 2 [ 2T(n/4) + n/2 ] + n
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n T(n) = 2T(n/2) + n = 2 [ 2T(n/4) + n/2 ] + n = 4T(n/4) + 2n = 4 [ 2T(n/8) n/4 ] + n = 8T(n/8) + 3n = 16T(n/16) + 4n = ... = (2^k)T(n/(2^k)) + kn
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn T(1) = c Merge Sort
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn T(1) = c n/(2^k) = 1 Merge Sort
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn T(1) = c n/(2^k) = 1 2^k = n Merge Sort
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn T(1) = c n/(2^k) = 1 2^k = n k = lg n Merge Sort
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn k = lg n T(n) = Merge Sort
Recurrence relation T(n) = c if n == 1 =
2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn k = lg n T(n) = (2^lg n)T(1) + n lg n Merge Sort
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn k = lg n T(n) = (2^lg n)T(1) + n lg n = cn + n lg n
Merge Sort Recurrence relation T(n) = c if n ==
1 = 2T(n/2) + n T(n) = (2^k)T(n/(2^k)) + kn k = lg n T(n) = (2^lg n)T(1) + n lg n = cn + n lg n O(n log n)
Does it matter?
Data Structures
Arrays vs Linked Lists
Binary Search Tree
B+ Trees
Back to Fibonacci… Why was it bad?
Fibonacci
Fibonacci
Fibonacci
Fibonacci
Fast Fibonacci
Paradigms / Techniques
Divide and Conquer Dynamic Programming Greedy Paradigms / Techniques
The Classics
Fast Fourier Transform Page Rank Dijkstra Miller-Rabin The Classics
Thank you!