Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Computational complexity theory
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Best, worst and average case complexity=== [[File:Sorting quicksort anim.gif|thumb|Visualization of the [[quicksort]] [[algorithm]], which has [[Best, worst and average case|average case performance]] <math>\mathcal{O}(n\log n)</math>]] The [[best, worst and average case]] complexity refer to three different ways of measuring the time complexity (or any other complexity measure) of different inputs of the same size. Since some inputs of size <math>n</math> may be faster to solve than others, we define the following complexities: # Best-case complexity: This is the complexity of solving the problem for the best input of size <math>n</math>. # Average-case complexity: This is the complexity of solving the problem on an average. This complexity is only defined with respect to a [[probability distribution]] over the inputs. For instance, if all inputs of the same size are assumed to be equally likely to appear, the average case complexity can be defined with respect to the uniform distribution over all inputs of size <math>n</math>. # [[Amortized analysis]]: Amortized analysis considers both the costly and less costly operations together over the whole series of operations of the algorithm. # Worst-case complexity: This is the complexity of solving the problem for the worst input of size <math>n</math>. The order from cheap to costly is: Best, average (of [[discrete uniform distribution]]), amortized, worst. For example, the deterministic sorting algorithm [[quicksort]] addresses the problem of sorting a list of integers. The worst-case is when the pivot is always the largest or smallest value in the list (so the list is never divided). In this case, the algorithm takes time [[Big O notation|O]](<math>n^2</math>). If we assume that all possible permutations of the input list are equally likely, the average time taken for sorting is <math>O(n \log n)</math>. The best case occurs when each pivoting divides the list in half, also needing <math>O(n \log n)</math> time.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Computational complexity theory
(section)
Add topic