-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy paths14.ps
More file actions
1352 lines (1320 loc) · 27.4 KB
/
s14.ps
File metadata and controls
1352 lines (1320 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!PS-Adobe-2.0
%%Copyright: Copyright (c) 1993 AT&T, All Rights Reserved
%%Version: 3.4
%%DocumentFonts: (atend)
%%Pages: (atend)
%%BoundingBox: (atend)
%%EndComments
/DpostDict 200 dict def
DpostDict begin
%
% Copyright (c) 1993 AT&T, All Rights Reserved
%
% Version 3.4 prologue for troff files.
%
/#copies 1 store
/Prologue (dpost.ps) def
/aspectratio 1 def
/formsperpage 1 def
/landscape false def
/linewidth .3 def
/magnification 1 def
/margin 0 def
/orientation 0 def
/resolution 720 def
/rotation 1 def
/xoffset 0 def
/yoffset 0 def
/roundpage true def
/useclippath true def
/pagebbox [0 0 612 792] def
/R /Times-Roman def
/I /Times-Italic def
/B /Times-Bold def
/BI /Times-BoldItalic def
/H /Helvetica def
/HI /Helvetica-Oblique def
/HB /Helvetica-Bold def
/HX /Helvetica-BoldOblique def
/CW /Courier def
/CO /Courier def
/CI /Courier-Oblique def
/CB /Courier-Bold def
/CX /Courier-BoldOblique def
/PA /Palatino-Roman def
/PI /Palatino-Italic def
/PB /Palatino-Bold def
/PX /Palatino-BoldItalic def
/Hr /Helvetica-Narrow def
/Hi /Helvetica-Narrow-Oblique def
/Hb /Helvetica-Narrow-Bold def
/Hx /Helvetica-Narrow-BoldOblique def
/KR /Bookman-Light def
/KI /Bookman-LightItalic def
/KB /Bookman-Demi def
/KX /Bookman-DemiItalic def
/AR /AvantGarde-Book def
/AI /AvantGarde-BookOblique def
/AB /AvantGarde-Demi def
/AX /AvantGarde-DemiOblique def
/NR /NewCenturySchlbk-Roman def
/NI /NewCenturySchlbk-Italic def
/NB /NewCenturySchlbk-Bold def
/NX /NewCenturySchlbk-BoldItalic def
/ZD /ZapfDingbats def
/ZI /ZapfChancery-MediumItalic def
/S /S def
/S1 /S1 def
/GR /Symbol def
/inch {72 mul} bind def
/min {2 copy gt {exch} if pop} bind def
/setup {
counttomark 2 idiv {def} repeat pop
landscape {/orientation 90 orientation add def} if
/scaling 72 resolution div def
linewidth setlinewidth
1 setlinecap
pagedimensions
xcenter ycenter translate
orientation rotation mul rotate
width 2 div neg height 2 div translate
xoffset inch yoffset inch neg translate
margin 2 div dup neg translate
magnification dup aspectratio mul scale
scaling scaling scale
addmetrics
0 0 moveto
} def
/pagedimensions {
useclippath userdict /gotpagebbox known not and {
/pagebbox [clippath pathbbox newpath] def
roundpage currentdict /roundpagebbox known and {roundpagebbox} if
} if
pagebbox aload pop
4 -1 roll exch 4 1 roll 4 copy
landscape {4 2 roll} if
sub /width exch def
sub /height exch def
add 2 div /xcenter exch def
add 2 div /ycenter exch def
userdict /gotpagebbox true put
} def
/landscapepage {
landscape not {
0 height scaling div neg translate % not quite
90 rotate
} if
} bind def
/portraitpage {
landscape {
width scaling div 0 translate % not quite
-90 rotate
} if
} bind def
/addmetrics {
/Symbol /S null Sdefs cf
/Times-Roman /S1 StandardEncoding dup length array copy S1defs cf
} def
/pagesetup {
/page exch def
currentdict /pagedict known currentdict page known and {
page load pagedict exch get cvx exec
} if
} def
/decodingdefs [
{counttomark 2 idiv {y moveto show} repeat}
{neg /y exch def counttomark 2 idiv {y moveto show} repeat}
{neg moveto {2 index stringwidth pop sub exch div 0 32 4 -1 roll widthshow} repeat}
{neg moveto {spacewidth sub 0.0 32 4 -1 roll widthshow} repeat}
{counttomark 2 idiv {y moveto show} repeat}
{neg setfunnytext}
] def
/setdecoding {/t decodingdefs 3 -1 roll get bind def} bind def
/w {neg moveto show} bind def
/m {neg dup /y exch def moveto} bind def
/done {/lastpage where {pop lastpage} if} def
/f {
dup /font exch def findfont exch
dup /ptsize exch def scaling div dup /size exch def scalefont setfont
linewidth ptsize mul scaling 10 mul div setlinewidth
/spacewidth ( ) stringwidth pop def
} bind def
/changefont {
/fontheight exch def
/fontslant exch def
currentfont [
1 0
fontheight ptsize div fontslant sin mul fontslant cos div
fontheight ptsize div
0 0
] makefont setfont
} bind def
/sf {f} bind def
/cf {
dup length 2 idiv
/entries exch def
/chtab exch def
/newencoding exch def
/newfont exch def
findfont dup length 1 add dict
/newdict exch def
{1 index /FID ne {newdict 3 1 roll put}{pop pop} ifelse} forall
newencoding type /arraytype eq {newdict /Encoding newencoding put} if
newdict /Metrics entries dict put
newdict /Metrics get
begin
chtab aload pop
1 1 entries {pop def} for
newfont newdict definefont pop
end
} bind def
%
% A few arrays used to adjust reference points and character widths in some
% of the printer resident fonts. If square roots are too high try changing
% the lines describing /radical and /radicalex to,
%
% /radical [0 -75 550 0]
% /radicalex [-50 -75 500 0]
%
% Move braceleftbt a bit - default PostScript character is off a bit.
%
/Sdefs [
/bracketlefttp [201 500]
/bracketleftbt [201 500]
/bracketrighttp [-81 380]
/bracketrightbt [-83 380]
/braceleftbt [203 490]
/bracketrightex [220 -125 500 0]
/radical [0 0 550 0]
/radicalex [-50 0 500 0]
/parenleftex [-20 -170 0 0]
/integral [100 -50 500 0]
/infinity [10 -75 730 0]
] def
/S1defs [
/underscore [0 80 500 0]
/endash [7 90 650 0]
] def
end
%%EndProlog
%%BeginSetup
DpostDict begin
mark
/rotation 1 def
/gotpagebbox true def
/linewidth 0.5 def
/xoffset 0 def
/yoffset 0 def
/#copies 1 store
/magnification 1 def
%%FormsPerPage: 1
/formsperpage 1 def
%%Patch from lp
%%EndPatch from lp
/landscape false def
/resolution 720 def
setup
2 setdecoding
%
% Copyright (c) 1993 AT&T, All Rights Reserved
%
% Version 3.4 drawing procedures for dpost. Automatically pulled in when
% needed.
%
/inpath false def
/savematrix matrix def
/Dl {
inpath
{pop pop neg lineto}
{newpath neg moveto neg lineto stroke}
ifelse
} bind def
/De {
/y1 exch 2 div def
/x1 exch 2 div def
/savematrix savematrix currentmatrix def
neg exch x1 add exch translate
x1 y1 scale
0 0 1 0 360
inpath
{1 0 moveto arc savematrix setmatrix}
{newpath arc savematrix setmatrix stroke}
ifelse
} bind def
/Da {
/dy2 exch def
/dx2 exch def
/dy1 exch def
/dx1 exch def
dy1 add neg exch dx1 add exch
dx1 dx1 mul dy1 dy1 mul add sqrt
dy1 dx1 neg atan
dy2 neg dx2 atan
inpath
{arc}
{newpath arc stroke}
ifelse
} bind def
/DA {
/dy2 exch def
/dx2 exch def
/dy1 exch def
/dx1 exch def
dy1 add neg exch dx1 add exch
dx1 dx1 mul dy1 dy1 mul add sqrt
dy1 dx1 neg atan
dy2 neg dx2 atan
inpath
{arcn}
{newpath arcn stroke}
ifelse
} bind def
/Ds {
/y2 exch def
/x2 exch def
/y1 exch def
/x1 exch def
/y0 exch def
/x0 exch def
x0 5 x1 mul add 6 div
y0 5 y1 mul add -6 div
x2 5 x1 mul add 6 div
y2 5 y1 mul add -6 div
x1 x2 add 2 div
y1 y2 add -2 div
inpath
{curveto}
{newpath x0 x1 add 2 div y0 y1 add -2 div moveto curveto stroke}
ifelse
} bind def
end
%%EndSetup
%%Page: 1 1
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
1 pagesetup
20 H f
(Heaps)2590 960 w
(The Data Structure)2 1696 1 720 1548 t
(Two Critical Functions)2 1970 1 720 1788 t
(Priority Queues)1 1382 1 720 2028 t
(A Sorting Algorithm)2 1728 1 720 2268 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-1)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 1 1
%%Page: 2 2
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
2 pagesetup
20 H f
(The Data Structure)2 1696 1 2212 960 t
(A Heap of Twelve Integers)4 2366 1 720 1488 t
16 H f
(12)3089 1984 w
(20)2138 2272 w
3102 2064 2228 2100 Dl
(15)4039 2272 w
3255 2064 4129 2100 Dl
(29)1663 2560 w
2152 2352 1753 2388 Dl
(23)2614 2560 w
2305 2352 2704 2388 Dl
(17)3564 2560 w
4053 2352 3654 2388 Dl
(22)4514 2560 w
4205 2352 4604 2388 Dl
(35)1426 2848 w
1678 2640 1516 2676 Dl
(40)1901 2848 w
1829 2640 1991 2676 Dl
(26)2376 2848 w
2628 2640 2466 2676 Dl
(51)2851 2848 w
2779 2640 2941 2676 Dl
(19)3326 2848 w
3578 2640 3416 2676 Dl
20 H f
(Two Properties of a Heap)4 2276 1 720 3492 t
20 HI f
(Order:)1008 3900 w
20 H f
(The value at any node is less than or)8 3284 1 1632 3900 t
( \(Thus)1 624(equal to the values of the node's children.)7 3710 2 1008 4140 t
(the least element of the set is at the root\).)9 3698 1 1008 4380 t
20 HI f
(Shape:)1008 4788 w
3368 5729 2340 5729 Dl
3368 5647 3368 5729 Dl
3779 5646 3368 5646 Dl
3060 5112 3780 5646 Dl
2340 5729 3060 5112 Dl
20 H f
(Warning)720 6293 w
(These heaps all use 1-based arrays)5 3192 1 1008 6701 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-2)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 2 2
%%Page: 3 3
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
3 pagesetup
20 H f
(Implementation of Trees with Shape)4 3214 1 1597 960 t
(A 12-Element Example)2 2052 1 720 1488 t
16 HI f
(x)3030 1948 w
16 H f
([ 1 ])2 206 1 3123 1948 t
16 HI f
(x)2079 2164 w
16 H f
([ 2 ])2 206 1 2172 2164 t
3135 1992 2228 2028 Dl
16 HI f
(x)3980 2164 w
16 H f
([ 3 ])2 206 1 4073 2164 t
3222 1992 4129 2028 Dl
16 HI f
(x)1604 2380 w
16 H f
([ 4 ])2 206 1 1697 2380 t
2185 2208 1753 2244 Dl
16 HI f
(x)2555 2380 w
16 H f
([ 5 ])2 206 1 2648 2380 t
2272 2208 2704 2244 Dl
16 HI f
(x)3505 2380 w
16 H f
([ 6 ])2 206 1 3598 2380 t
4086 2208 3654 2244 Dl
16 HI f
(x)4455 2380 w
16 H f
([ 7 ])2 206 1 4548 2380 t
4172 2208 4604 2244 Dl
16 HI f
(x)1367 2596 w
16 H f
([ 8 ])2 206 1 1460 2596 t
1710 2424 1516 2460 Dl
16 HI f
(x)1842 2596 w
16 H f
([ 9 ])2 206 1 1935 2596 t
1797 2424 1991 2460 Dl
16 HI f
(x)2272 2596 w
16 H f
([ 10 ])2 296 1 2365 2596 t
2660 2424 2466 2460 Dl
16 HI f
(x)2747 2596 w
16 H f
([ 11 ])2 296 1 2840 2596 t
2747 2424 2941 2460 Dl
16 HI f
(x)3222 2596 w
16 H f
([ 12 ])2 296 1 3315 2596 t
3610 2424 3416 2460 Dl
20 H f
(Definitions in a Program)3 2140 1 720 3204 t
20 CW f
(root = 1)2 960 1 1296 3499 t
(value\(i\) = x[i])2 1800 1 1296 3734 t
(leftchild\(i\) = 2*i)2 2160 1 1296 3969 t
(rightchild\(i\) = 2*i+1)2 2520 1 1296 4204 t
(parent\(i\) = i / 2)4 2040 1 1296 4439 t
(null\(i\) = \(i < 1\) or \(i > n\))8 3360 1 1296 4674 t
20 H f
(A Tree and Its Array)4 1796 1 720 5142 t
16 H f
(12)2970 5584 w
(20)2250 5764 w
3016 5610 2340 5646 Dl
(15)3690 5764 w
3104 5610 3780 5646 Dl
(29)1890 5944 w
2296 5790 1980 5826 Dl
(23)2610 5944 w
2384 5790 2700 5826 Dl
(17)3330 5944 w
3736 5790 3420 5826 Dl
(22)4050 5944 w
3824 5790 4140 5826 Dl
(35)1710 6124 w
1936 5970 1800 6006 Dl
(40)2070 6124 w
2024 5970 2160 6006 Dl
(26)2430 6124 w
2656 5970 2520 6006 Dl
(51)2790 6124 w
2744 5970 2880 6006 Dl
(19)3150 6124 w
3376 5970 3240 6006 Dl
(12)1386 6614 w
1332 6654 1332 6510 Dl
(1)1431 6806 w
1620 6654 1332 6654 Dl
(20)1674 6614 w
1908 6654 1620 6654 Dl
(15)1962 6614 w
2196 6654 1908 6654 Dl
(29)2250 6614 w
2484 6654 2196 6654 Dl
(23)2538 6614 w
2772 6654 2484 6654 Dl
(17)2826 6614 w
3060 6654 2772 6654 Dl
(22)3114 6614 w
3348 6654 3060 6654 Dl
(35)3402 6614 w
3636 6654 3348 6654 Dl
(40)3690 6614 w
3924 6654 3636 6654 Dl
(26)3978 6614 w
4212 6654 3924 6654 Dl
(51)4266 6614 w
4500 6654 4212 6654 Dl
(19)4554 6614 w
4788 6654 4500 6654 Dl
4788 6510 4788 6654 Dl
(12)4554 6806 w
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-3)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 3 3
%%Page: 4 4
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
4 pagesetup
20 H f
(The siftup Function)2 1708 1 2206 960 t
(The Goal)1 826 1 720 1488 t
20 HI f
(x)1008 1896 w
20 H f
([ 1)1 184 1 1124 1896 t
20 HI f
(.)1324 1896 w
20 H f
(.)1380 1896 w
20 HI f
(n)1452 1896 w
20 S f
(-)1613 1896 w
20 H f
( is a heap; put a new element in)8 2838(1 ])1 184 2 1756 1896 t
20 HI f
(x)4834 1896 w
20 H f
([)4950 1896 w
20 HI f
(n)5022 1896 w
20 H f
(].)5150 1896 w
(Sift the new element up the tree.)6 2894 1 1008 2136 t
(Inserting 13)1 1050 1 720 2544 t
16 H f
(12)1450 2979 w
(20)1018 3231 w
1501 2998 1108 3120 Dl
(15)1882 3231 w
1579 2998 1972 3120 Dl
(29)802 3483 w
1069 3250 892 3372 Dl
(23)1234 3483 w
1147 3250 1324 3372 Dl
(17)1666 3483 w
1933 3250 1756 3372 Dl
(22)2098 3483 w
2011 3250 2188 3372 Dl
(35)694 3735 w
853 3502 784 3624 Dl
(40)910 3735 w
931 3502 1000 3624 Dl
(26)1126 3735 w
1285 3502 1216 3624 Dl
(51)1342 3735 w
1363 3502 1432 3624 Dl
(19)1558 3735 w
1717 3502 1648 3624 Dl
(13)1774 3735 w
1795 3502 1864 3624 Dl
1791 3697 146 146 De
(12)3178 2979 w
(20)2746 3231 w
3229 2998 2836 3120 Dl
(15)3610 3231 w
3307 2998 3700 3120 Dl
(29)2530 3483 w
2797 3250 2620 3372 Dl
(23)2962 3483 w
2875 3250 3052 3372 Dl
(13)3394 3483 w
3661 3250 3484 3372 Dl
(22)3826 3483 w
3739 3250 3916 3372 Dl
(35)2422 3735 w
2581 3502 2512 3624 Dl
(40)2638 3735 w
2659 3502 2728 3624 Dl
(26)2854 3735 w
3013 3502 2944 3624 Dl
(51)3070 3735 w
3091 3502 3160 3624 Dl
(19)3286 3735 w
3445 3502 3376 3624 Dl
(17)3502 3735 w
3523 3502 3592 3624 Dl
3411 3445 146 146 De
(12)4906 2979 w
(20)4474 3231 w
4957 2998 4564 3120 Dl
(13)5338 3231 w
5035 2998 5428 3120 Dl
(29)4258 3483 w
4525 3250 4348 3372 Dl
(23)4690 3483 w
4603 3250 4780 3372 Dl
(15)5122 3483 w
5389 3250 5212 3372 Dl
(22)5554 3483 w
5467 3250 5644 3372 Dl
(35)4150 3735 w
4309 3502 4240 3624 Dl
(40)4366 3735 w
4387 3502 4456 3624 Dl
(26)4582 3735 w
4741 3502 4672 3624 Dl
(51)4798 3735 w
4819 3502 4888 3624 Dl
(19)5014 3735 w
5173 3502 5104 3624 Dl
(17)5230 3735 w
5251 3502 5320 3624 Dl
5355 3193 146 146 De
20 H f
(The Code)1 882 1 720 4334 t
20 CW f
(void siftup\(n\))1 1680 1 864 4589 t
( > 0 && heap\(1, n-1\))5 2400(pre n)1 720 2 1824 4784 t
(post heap\(1, n\))2 1800 1 1824 4979 t
(i = n)2 600 1 1344 5174 t
(loop)1344 5369 w
(/* invariant: heap\(1, n\) except)4 3720 1 1824 5564 t
(between i and its parent */)5 3240 1 2304 5759 t
(if i == 1)3 1080 1 1824 5954 t
(break)2304 6149 w
(p = i / 2)4 1080 1 1824 6344 t
(if x[p] <= x[i])3 1800 1 1824 6539 t
(break)2304 6734 w
(swap\(p, i\))1 1200 1 1824 6929 t
(i = p)2 600 1 1824 7124 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-4)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 58 -1 583 726
%%EndPage: 4 4
%%Page: 5 5
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
5 pagesetup
20 H f
(The siftdown Function)2 1964 1 2078 960 t
(The Goal)1 826 1 720 1488 t
20 HI f
(x)1008 1896 w
20 H f
([ 2)1 184 1 1124 1896 t
20 HI f
(.)1324 1896 w
20 H f
(.)1380 1896 w
20 HI f
(n)1452 1896 w
20 H f
(] is a heap; sift)4 1296 1 1580 1896 t
20 HI f
(x)2932 1896 w
20 H f
( down, swapping with)3 1908([ 1 ])2 256 2 3048 1896 t
(the lesser child)2 1338 1 1008 2136 t
(Inserting 18)1 1050 1 720 2544 t
16 H f
(18)1450 2979 w
(20)1018 3231 w
1501 2998 1108 3120 Dl
(15)1882 3231 w
1579 2998 1972 3120 Dl
(29)802 3483 w
1069 3250 892 3372 Dl
(23)1234 3483 w
1147 3250 1324 3372 Dl
(17)1666 3483 w
1933 3250 1756 3372 Dl
(22)2098 3483 w
2011 3250 2188 3372 Dl
(35)694 3735 w
853 3502 784 3624 Dl
(40)910 3735 w
931 3502 1000 3624 Dl
(26)1126 3735 w
1285 3502 1216 3624 Dl
(51)1342 3735 w
1363 3502 1432 3624 Dl
(19)1558 3735 w
1717 3502 1648 3624 Dl
1467 2941 146 146 De
(15)3178 2979 w
(20)2746 3231 w
3229 2998 2836 3120 Dl
(18)3610 3231 w
3307 2998 3700 3120 Dl
(29)2530 3483 w
2797 3250 2620 3372 Dl
(23)2962 3483 w
2875 3250 3052 3372 Dl
(17)3394 3483 w
3661 3250 3484 3372 Dl
(22)3826 3483 w
3739 3250 3916 3372 Dl
(35)2422 3735 w
2581 3502 2512 3624 Dl
(40)2638 3735 w
2659 3502 2728 3624 Dl
(26)2854 3735 w
3013 3502 2944 3624 Dl
(51)3070 3735 w
3091 3502 3160 3624 Dl
(19)3286 3735 w
3445 3502 3376 3624 Dl
3627 3193 146 146 De
(15)4906 2979 w
(20)4474 3231 w
4957 2998 4564 3120 Dl
(17)5338 3231 w
5035 2998 5428 3120 Dl
(29)4258 3483 w
4525 3250 4348 3372 Dl
(23)4690 3483 w
4603 3250 4780 3372 Dl
(18)5122 3483 w
5389 3250 5212 3372 Dl
(22)5554 3483 w
5467 3250 5644 3372 Dl
(35)4150 3735 w
4309 3502 4240 3624 Dl
(40)4366 3735 w
4387 3502 4456 3624 Dl
(26)4582 3735 w
4741 3502 4672 3624 Dl
(51)4798 3735 w
4819 3502 4888 3624 Dl
(19)5014 3735 w
5173 3502 5104 3624 Dl
5139 3445 146 146 De
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-5)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 58 -1 583 726
%%EndPage: 5 5
%%Page: 6 6
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
6 pagesetup
18 H f
(siftdown code)1 1106 1 2507 960 t
20 CW f
(void siftdown\(n\))1 1920 1 720 1543 t
( n\) && n >= 0)5 1560(pre heap\(2,)1 1560 2 1680 1778 t
( n\))1 360(post heap\(1,)1 1560 2 1680 2013 t
(i = 1)2 600 1 1200 2248 t
(loop)1200 2483 w
(/* inv: heap\(1, n\) except between)5 3960 1 1680 2718 t
(i and its 0, 1 or 2 kids */)8 3240 1 2160 2953 t
(c = 2*i)2 840 1 1680 3188 t
(if c > n)3 960 1 1680 3423 t
(break)2160 3658 w
(/* c is the left child of i */)8 3600 1 1680 3893 t
(if c+1 <= n)3 1320 1 1680 4128 t
(/* c+1 is the right child of i */)8 3960 1 2160 4363 t
(if x[c+1] < x[c])3 1920 1 2160 4598 t
(c++)2640 4833 w
(/* c is the lesser child of i */)8 3840 1 1680 5068 t
(if x[i] <= x[c])3 1800 1 1680 5303 t
(break)2160 5538 w
(swap\(c, i\))1 1200 1 1680 5773 t
(i = c)2 600 1 1680 6008 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-14-6)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 622 724
%%EndPage: 6 6
%%Page: 7 7
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
7 pagesetup
20 H f
(Priority Queues)1 1382 1 2369 960 t
(The Abstract Data Type)3 2120 1 720 1488 t
(Operations on \(initially empty\) set)4 2976 1 1008 1896 t
20 HI f
(S)4040 1896 w
20 H f
(.)4174 1896 w
20 CW f
(void insert\(t\))1 1680 1 1008 2191 t
( < maxsize)2 1200(pre |S|)1 960 2 1248 2426 t
(post current S = original S)5 3240 1 1248 2661 t
20 S f
(\310)4608 2661 w
20 CW f
({t})4882 2661 w
(int extractmin\(\))1 1920 1 1008 3131 t
( > 0)2 480(pre |S|)1 960 2 1248 3366 t
(post original S = current S)5 3240 1 1248 3601 t
20 S f
(\310)4608 3601 w
20 CW f
({result})4882 3601 w
(&& result = min\(original S\))4 3240 1 1848 3836 t
20 H f
(Implementations)720 4304 w
18 S f
(_ __________________________________________________)1 4531 1 794 4474 t
(_ __________________________________________________)1 4531 1 794 4494 t
18 H f
(R)3291 4724 w
16 H f
(UN)3421 4724 w
18 H f
(T)3701 4724 w
16 H f
(IMES)3811 4724 w
18 S f
(_ ____________________________________)1 3290 1 2035 4784 t
18 H f
(S)847 4874 w
16 H f
(TRUCTURE)968 4874 w
18 H f
(1)2237 5024 w
18 HI f
(insert)2388 5024 w
18 H f
(1)3166 5024 w
18 HI f
(extractmin n)1 1283 1 3317 5024 t
18 H f
(of each)1 594 1 4650 5024 t
18 S f
(_ __________________________________________________)1 4531 1 794 5084 t
18 H f
(Sorted Seq)1 906 1 794 5324 t
18 HI f
(O)2331 5324 w
18 H f
(\()2486 5324 w
18 HI f
(n)2560 5324 w
18 H f
(\))2676 5324 w
18 HI f
(O)3455 5324 w
18 H f
(\( 1 \))2 249 1 3610 5324 t
18 HI f
(O)4607 5324 w
18 H f
(\()4762 5324 w
18 HI f
(n)4836 5324 w
15 H f
(2)4962 5252 w
18 H f
(\))5076 5324 w
(Heaps)794 5564 w
18 HI f
(O)2170 5564 w
18 H f
(\( log)1 316 1 2325 5564 t
18 HI f
(n)2721 5564 w
18 H f
(\))2837 5564 w
18 HI f
(O)3294 5564 w
18 H f
(\( log)1 316 1 3449 5564 t
18 HI f
(n)3845 5564 w
18 H f
(\))3961 5564 w
18 HI f
(O)4418 5564 w
18 H f
(\()4573 5564 w
18 HI f
(n)4647 5564 w
18 H f
(log)4828 5564 w
18 HI f
(n)5150 5564 w
18 H f
(\))5266 5564 w
(Unsorted Seq)1 1106 1 794 5804 t
18 HI f
(O)2331 5804 w
18 H f
(\( 1 \))2 249 1 2486 5804 t
18 HI f
(O)3455 5804 w
18 H f
(\()3610 5804 w
18 HI f
(n)3684 5804 w
18 H f
(\))3800 5804 w
18 HI f
(O)4607 5804 w