patternMinor
Isn't linear time O(n)?
Viewed 0 times
isnlineartime
Problem
In the question in this video about quicksort luckily picking the median in each recursive call. Tim Roughgarden, the presenter, says at 11:22
Partition needs really linear time, not just $O(n)$ time.
What does he mean here? I thought linear time is $O(n)$. Does he mean $\Theta(n)$ or something else? I see how partition in quicksort here would be $\Theta(n)$ but I don't get the part that says "not just $O(n)$ time".
Partition needs really linear time, not just $O(n)$ time.
What does he mean here? I thought linear time is $O(n)$. Does he mean $\Theta(n)$ or something else? I see how partition in quicksort here would be $\Theta(n)$ but I don't get the part that says "not just $O(n)$ time".
Solution
Usually we call statement $A$ stronger than $B$ when $A$ implies $B$: $A \Rightarrow B$ (weaker-stronger). In other words, $B$ is weaker than $A$.
When the presenter is speaking about linear time for partition, this is a stronger statement than $O(n)$ time. All linear functions are in $O(n)$, but it also contains non-linear functions.
For example: $\sin n, \frac{1}{n}, \sqrt{n} $ are all in $O(n)$, but they are not linear. As was written in a comment, $O(n)$ is the set of functions bounded by linear functions, but not the set of only linear functions.
To be linear gives more information than to be in $O(n)$, to be in $\Omega(n)$, even to be in $\Theta(n)$.
When the presenter is speaking about linear time for partition, this is a stronger statement than $O(n)$ time. All linear functions are in $O(n)$, but it also contains non-linear functions.
For example: $\sin n, \frac{1}{n}, \sqrt{n} $ are all in $O(n)$, but they are not linear. As was written in a comment, $O(n)$ is the set of functions bounded by linear functions, but not the set of only linear functions.
To be linear gives more information than to be in $O(n)$, to be in $\Omega(n)$, even to be in $\Theta(n)$.
Context
StackExchange Computer Science Q#134138, answer score: 8
Revisions (0)
No revisions yet.