/frames 8 def %include /u/rs/book3/pslib/tools.ps /dx 6 def /dy 6 def /ox 0 def /oy 3 def /myscale {dy mul oy add exch dx mul ox add exch} def %include /u/rs/book3/pslib/points.ps [ 49 { 0 } repeat ] /A exch def A length /N exch def /LL 0 def /RR N 1 sub def /frame frames 1 sub def /nextframe {/frame frame 1 sub def} def /lastframe {/frame frame 1 add def} def /ptChar 1 string def /PT { /II exch def ptChar 0 A II get 64 add put ptChar exch II 1 add frame pt } def /ptNum 2 string def /PTnum { /II exch def A II get ptNum cvs exch II 1 add frame pt } def /INITFILE { [ 49 { 0 } repeat ] /A exch def } def /MARKFILE { /incr exch def /offs exch def LL 1 RR { /xxx exch def RR xxx sub offs sub dup 0 gt exch incr mod 0 eq and { A xxx 1 put }{} ifelse } for } def /DRAWFILE { LL 1 RR { CellWh exch PT } for LL 1 RR { dup A exch get 0 eq { CellWh }{ CellGr } ifelse exch PT } for CellGr RR PT nextframe } def /LABELS { INITFILE A RR 4 sub 4 put A RR 8 sub 8 put A RR 13 sub 13 put A RR 26 sub 26 put A RR 39 sub 39 put LL 1 RR { dup A exch get 0 ne { 3 exch PTnum }{ pop } ifelse } for nextframe } def 0 4 MARKFILE DRAWFILE INITFILE 9 4 MARKFILE DRAWFILE INITFILE 22 4 MARKFILE DRAWFILE INITFILE 35 4 MARKFILE DRAWFILE INITFILE nextframe 0 4 MARKFILE 9 4 MARKFILE 22 4 MARKFILE 35 4 MARKFILE DRAWFILE nextframe LABELS ---------------------------- Med 4pc A 4- and 13- ordered file. The bottom row depicts an array with shaded boxes depicting those items that must be smaller than or equal to the item at the far right, if the array is both 4- and 13-ordered. The four rows at top depict the origin of the pattern. If the item at right is at array position $i$, then 4-ordering means that items at array positions $i-4$, $i-8$, $i-12$, $\ldots$ are smaller or equal \itpc{top}; 13-ordering means that the item at $i-13$, and therefore, because of 4-ordering, the items at $i-17$, $i-21$, $i-25$, $\ldots$ are smaller or equal \itpc{second from top}; also the item at $i-26$, and therefore, because of 4-ordering, the items at $i-30$, $i-34$, $i-38$, $\ldots$ are smaller or equal \itpc{third from top}; and so forth. The white squares left are those than could be larger than the item at left; there are at most 18 such items. Thus there are at most $18N$ comparisons required to insertionsort a 13-ordered and 4-ordered file of size $N$.