/wideflag 1 def /frames 5 def /figflag 2 def %include /u/rs/book3/pslib/tools.ps %include /u/rs/book3/pslib/angles.ps /shellsort { { /inc exch def 1 1 N {inc neg inc 1 add {dup inc sub compareswap} for } for ARRAY inc 1 eq { exit } if } loop } def N randomperm /A exch def /A [ 0 A aload pop ] def /LL 1 def /RR N 1 sub def ARRAY 1 4 13 40 shellsort ---------------------------- Med 8.666pc Shellsorting a random permutation The effect of each of the passes in Shellsort is to bring the file as a whole closer to sorted order. The file is first 40-sorted, then 13-sorted, then 4-sorted, then 1-sorted. Each pass brings the file closer to sorted order.