My algorithm should work on that specific instance, though, because about 1/4 of the (i,j) pairs are unsorted. (I'm not picking them consecutively)
My algorithm should work on that specific instance, though, because about 1/4 of the (i,j) pairs are unsorted. (I'm not picking them consecutively)
choose 2 random indices i < j
if a[i] > a[j] return "unsorted"
return "sorted"
I think the above would work? Each iteration should have ~10% chance to find an unsorted pair (maybe not obvious), so only error with .9^k < 1/poly(n)
choose 2 random indices i < j
if a[i] > a[j] return "unsorted"
return "sorted"
I think the above would work? Each iteration should have ~10% chance to find an unsorted pair (maybe not obvious), so only error with .9^k < 1/poly(n)