← All reports

Rust Report — CSC 482 HW3 (Language Comparison)

Language / toolchain

Algorithm / RNG

Implements CLRS's RANDOMIZED-QUICKSORT / RANDOMIZED-PARTITION (Ch. 5) directly:

External code used

Results

Full results (also in HW3/results/rust.csv), 17 iterations, stopped when iteration 17 (n = 65,536,000) took 5.878s, exceeding the 4.0s cutoff:

n time_seconds
1,000 0.000042752
2,000 0.000101453
4,000 0.000187246
8,000 0.000409067
16,000 0.000851156
32,000 0.001742651
64,000 0.003595190
128,000 0.007541507
256,000 0.015842399
512,000 0.032315980
1,024,000 0.067801550
2,048,000 0.138964908
4,096,000 0.289725853
8,192,000 0.590679369
16,384,000 1.372611172
32,768,000 3.000116328
65,536,000 5.878090235

Max n reached: 65,536,000, time 5.878s (this is the iteration that triggered the stop, per the >4.0s rule). Total wall-clock time for the whole run (build excluded, time around the binary invocation): ~12.08s real.

Growth analysis

For O(n log n) behavior, doubling n should roughly double the runtime times a slowly growing log factor — i.e., the ratio T(2n)/T(n) should be a bit above 2 and should trend slightly upward (or stay roughly flat) as n grows, converging toward 2 from above since log(2n)/log(n) → 1 as n → ∞. The observed per-doubling ratios in this run are consistently in the ~2.0–2.3x range across nearly the entire table (e.g., 8,000→16,000 is 2.08x, 128,000→256,000 is 2.10x, 1,024,000→2,048,000 is 2.05x, 4,096,000→8,192,000 is 2.04x), which matches expected O(n log n) growth well — a pure O(n) algorithm would show ratios flat at ~2.0x, while O(n^2) would show ratios near 4.0x; the data sits just above the linear line, consistent with the extra log n factor. The two smallest transitions (n=1000→2000 at 2.37x and n=2000→4000 at 1.85x) are the main anomaly and are attributable to measurement noise at microsecond scale — timer resolution, one-time allocator/OS page-fault warmup on the first few Vec allocations, and CPU frequency ramp-up, all of which have outsized relative effect when the timed interval itself is only tens of microseconds. No other anomalies (no GC, no JIT in Rust) were observed; the largest iterations show smooth, consistent scaling right up to the 4-second cutoff.