I was going through lecture videos by Robert Sedgwick on algorithms, and he explains that random shuffling ensures we don\'t get to encounter the worst case quadratic time s
Is the video in coursera? Unfortunately, shuffle decrease performance to O(N^2) with data n,n,...,n,1,1,...,1. I have inspected Quick.java with nn11.awk that generate such data.
$ for N in 10000 20000 30000 40000; do time ./nn11.awk $N | java Quick; done | awk 'NF>1'
real 0m10.732s
user 0m10.295s
sys 0m0.948s
real 0m48.057s
user 0m44.968s
sys 0m3.193s
real 1m52.109s
user 1m48.158s
sys 0m3.634s
real 3m38.336s
user 3m31.475s
sys 0m6.253s