/frames 8 def /NN 420 def /rows 2 def /figflag 2 def /SNAP NN NN 8 div sub def /Ndots NN def %include /u/rs/book3/pslib/tools.ps %include /u/rs/book3/pslib/dots.ps /swap {/ii exch def /jj exch def A ii get /t exch def A ii A jj get put A jj t put } def /partition { /r exch def /l exch def /v A r get def /j r def /i l 1 sub def { { /j j 1 sub def A j get v le { exit } if } loop { /i i 1 add def A i get v ge { exit } if } loop j i lt { exit } if j i swap j i sub SNAP lt {ARRAY /SNAP SNAP NN 8 div sub def} if } loop r i swap i } def newRow NN randomperm /A exch def 0 NN 1 sub partition pop ARRAY --------------------------------------- T 3.1pc Quicksort partitioning The partitioning process divides a file into two subfiles that can be sorted independently. None of the elements to the left of the left scan pointer are larger, so there are no dots above and to its left; and none of the elements to the right of the right scan pointer are smaller, so there are no dots below and to its right. Thus, when we plot the process for a randomly ordered array, partitioning divides a square of randomly arranged dots into two smaller squares, with one element (the partitioning element) ending up on the diagonal.