once per card. Analysis Technique 1 Analysis Technique 1
Late in the sort, we have to move up to
cards to make space on average. This depends on the size of the sorted space. Analysis Technique 1 We apply the strategy times. When applied to the th card in the original set, the strategy (on average) costs time. Analysis Technique 2
For cards, we apply the overall strategy
about times. Analysis Technique 2
Within each step, cards are only swapped
theres no major movement penalty. swaps are possible in each strategy step. Analysis Technique 2
swaps are possible in each strategy step.
This is regardless of which step were in even later steps sum up to roughly . Analysis Technique 2 We apply the strategy times. Each application costs roughly . Comparison When comparing techniques for large , the key part is the largest term. Technique 1: Technique 2: Comparison
Comparison For Technique 1:
Technique 2: (Note that )
Comparison vs thats a ratio of 25000:1. It only gets worse for larger .
The true coefficients (for the
dominant term) are more in favor of Technique 1 but at this scale, Technique 2 still wins, hands-down. Conclusion Note: Technique 1 is more intuitive than Technique 2. Only by studying and research did the more efficient Technique 2 come to be. In short, computer science.