How To Win Coding Competitions: Secrets of Champions: Pavel Krotkov Saint Petersburg 2016
How To Win Coding Competitions: Secrets of Champions: Pavel Krotkov Saint Petersburg 2016
Pavel Krotkov
Saint Petersburg 2016
Function comparison
2/9
Function comparison
2/9
Function comparison
2/9
Function comparison
2/9
Asymptotical equivalence
3/9
Asymptotical equivalence
3/9
Asymptotical equivalence
3/9
Asymptotical equivalence
3/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O and Ω
4/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
O properties
5/9
Asymptotical complexity
Consider a program
j = 1
for i = 1 to n
j = j × i
6/9
Asymptotical complexity
Consider a program
j = 1
for i = 1 to n
j = j × i
This cycle performs n iterations. Every iteration takes constant amount of operations.
6/9
Asymptotical complexity
Consider a program
j = 1
for i = 1 to n
j = j × i
This cycle performs n iterations. Every iteration takes constant amount of operations.
6/9
Asymptotical complexity
7/9
Asymptotical complexity
7/9
Asymptotical complexity
7/9
Estimating run time from complexity
Consider you have a program which takes one number n as an input. Let’s try to
estimate its run time from its complexity and value of n.
8/9
Estimating run time from complexity
Consider you have a program which takes one number n as an input. Let’s try to
estimate its run time from its complexity and value of n.
8/9
Estimating run time from complexity
Consider you have a program which takes one number n as an input. Let’s try to
estimate its run time from its complexity and value of n.
You can suppose that average amount of operations per second CPU can perform is
≈ 3 × 108 . That is precise enough to check if yor program will pass Time Limit.
8/9
Estimating run time from complexity
Consider you have a program which takes one number n as an input. Let’s try to
estimate its run time from its complexity and value of n.
You can suppose that average amount of operations per second CPU can perform is
≈ 3 × 108 . That is precise enough to check if yor program will pass Time Limit.
8/9
Estimating run time from complexity
Consider you have a program which takes one number n as an input. Let’s try to
estimate its run time from its complexity and value of n.
You can suppose that average amount of operations per second CPU can perform is
≈ 3 × 108 . That is precise enough to check if yor program will pass Time Limit.
8/9
Thank you
for your attention!
9/9