Chapter 1
Translated from Chinese by an LLM.
I never know what to write for each chapter - at a loss for words.
Binary Search
The complexity of binary search is .
As shown:
To make it clearer, I compared it with linear search . It’s easy to see the time difference is enormous.
Code implementation:
lower_bound();
upper_bound(); // STL
Big O Notation
A later chapter also covers this.
Comparison of time complexities:
The differences between time complexities are huge (I didn’t include - its growth rate is so large it would dwarf everything else).
is the constant factor of the time an algorithm needs. The actual running time is , where stands for any variable.
But in general, the time contributed by is not counted, even if it is very large. because the growth rate matters more.
Computation: with recursion, it is generally .
Worst Case vs. Average Case
Traveling Salesman Problem
P1433 Eating Cheese A classic traveling salesman problem (I don’t know how to solve it yet).