00 · Results
What the analysis found.
| Part | T(n) | Complexity |
|---|---|---|
| Writing & reading (FileService) | 4n + 6c | O(n) |
| Processing (Benchmarker) | Array copies O(n) + each sort | O(n) per copy |
| Selection Sort | 3n² + 3n + c | O(n²) |
| Insertion Sort | Nested while loop, O(n²) | O(n²) |
| Merge Sort | log n levels × O(n) merge | O(n log n) |
| Quick Sort | O(n) partition, recursive halves | O(n log n) |
01 · The writing and reading running time
FileService: O(n)
Reading delegates to the input validator, which is O(n). Writing loops over the array once, with a constant cost per record, so T(n) = 4n + 6c and the asymptotic time complexity is O(n).
02 · The processing run time
Benchmarker: copy, time, sort.
Each fresh copy of the array costs O(n). Timer calls and print statements are O(1). The sort calls themselves are analysed below.
03 · The sorting running time
Four algorithms, four derivations.
04 · Visualise it
How n, n log n and n² grow.
An interactive illustration of the three growth rates above. It plots basic operation counts, not milliseconds.
nn log₂ nn²
—more basic operations for n² than n log n when n = 3,432
n—
n log₂ n—
n²—