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
32
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
45
How do we create the first impressions?
cheesecakelabs
0
47
Menstrual cup: suit and freedom
cheesecakelabs
0
48
Life is a cycle, better with a bicycle
cheesecakelabs
0
44
Interview Process: how to get the best of people
cheesecakelabs
1
70
My capsule wardrobe experience
cheesecakelabs
3
49
Stonewall Rebellion and its impact on LGBTQIA+ history
cheesecakelabs
1
32
Pregnancy, childbirth and breastfeeding: What do I have to do with it?
cheesecakelabs
0
41
MBTI - Psychological types described by Jung
cheesecakelabs
0
110
Other Decks in Programming
See All in Programming
Jakarta EE meets AI
ivargrimstad
0
130
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
CSC509 Lecture 13
javiergs
PRO
0
110
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
200
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
CSC509 Lecture 09
javiergs
PRO
0
140
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
327
38k
BBQ
matthewcrist
85
9.3k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Designing for Performance
lara
604
68k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Side Projects
sachag
452
42k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
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!