Exercise: Quicksort Index   <<   >>
 

Q←{1≥≢⍵:⍵ ⋄ (∇ ⍵⌿⍨0>s)⍪(⍵⌿⍨0=s)⍪∇ ⍵⌿⍨0<s←⍵ ⍺⍺ ⍵⌷⍨?≢⍵}

S1←{⍵⌷⍨⍺⌷⍋⍵}

S←{
  s←⍵ ⍺⍺ p←⍵⌷⍨?≢⍵
  ⍺<  +/b←0>s:⍺ ∇ b⌿⍵
  ⍺<m←+/b←0≥s:p
  (⍺-m) ∇ (~b)⌿⍵
}

a.   Modify Q to catenate the enclose of the 3 parts.
 
b. Create Sn by modifying S to hardwire comparisons on numeric scalars.
 
c. Create a random numeric vector x←?1e6⍴1e9 and do benchmarks on S1 , S  , and Sn .
x ← ? 1e6⍴1e9
i ← ? ≢x
cmpx 'i S1 x' 'i -S x' 'i Sn x'