aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/HEAP.pht
blob: f7a9508843fe3f0d179167a2bf1c07c5cbd544bf (plain)
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
\begin{patch}{HeapXmpPagePatch1}
\begin{paste}{HeapXmpPageFull1}{HeapXmpPageEmpty1}
\pastebutton{HeapXmpPageFull1}{\hidepaste}
\tab{5}\spadcommand{h := heap [-4,9,11,2,7,-7]\bound{h }}
\indentrel{3}\begin{verbatim}
   (1)  [11,7,9,- 4,2,- 7]
                                     Type: Heap Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty1}
\begin{paste}{HeapXmpPageEmpty1}{HeapXmpPagePatch1}
\pastebutton{HeapXmpPageEmpty1}{\showpaste}
\tab{5}\spadcommand{h := heap [-4,9,11,2,7,-7]\bound{h }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch2}
\begin{paste}{HeapXmpPageFull2}{HeapXmpPageEmpty2}
\pastebutton{HeapXmpPageFull2}{\hidepaste}
\tab{5}\spadcommand{insert!(3,h)\bound{h1 }\free{h }}
\indentrel{3}\begin{verbatim}
   (2)  [11,7,9,- 4,2,- 7,3]
                                     Type: Heap Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty2}
\begin{paste}{HeapXmpPageEmpty2}{HeapXmpPagePatch2}
\pastebutton{HeapXmpPageEmpty2}{\showpaste}
\tab{5}\spadcommand{insert!(3,h)\bound{h1 }\free{h }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch3}
\begin{paste}{HeapXmpPageFull3}{HeapXmpPageEmpty3}
\pastebutton{HeapXmpPageFull3}{\hidepaste}
\tab{5}\spadcommand{extract! h\bound{h2 }\free{h1 }}
\indentrel{3}\begin{verbatim}
   (3)  11
                                  Type: PositiveInteger
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty3}
\begin{paste}{HeapXmpPageEmpty3}{HeapXmpPagePatch3}
\pastebutton{HeapXmpPageEmpty3}{\showpaste}
\tab{5}\spadcommand{extract! h\bound{h2 }\free{h1 }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch4}
\begin{paste}{HeapXmpPageFull4}{HeapXmpPageEmpty4}
\pastebutton{HeapXmpPageFull4}{\hidepaste}
\tab{5}\spadcommand{h\free{h2 }}
\indentrel{3}\begin{verbatim}
   (4)  [9,7,3,- 4,2,- 7]
                                     Type: Heap Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty4}
\begin{paste}{HeapXmpPageEmpty4}{HeapXmpPagePatch4}
\pastebutton{HeapXmpPageEmpty4}{\showpaste}
\tab{5}\spadcommand{h\free{h2 }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch5}
\begin{paste}{HeapXmpPageFull5}{HeapXmpPageEmpty5}
\pastebutton{HeapXmpPageFull5}{\hidepaste}
\tab{5}\spadcommand{[extract!(h) while not empty?(h)]\bound{h2 }}
\indentrel{3}\begin{verbatim}
   (5)  [9,7,3,2,- 4,- 7]
                                     Type: List Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty5}
\begin{paste}{HeapXmpPageEmpty5}{HeapXmpPagePatch5}
\pastebutton{HeapXmpPageEmpty5}{\showpaste}
\tab{5}\spadcommand{[extract!(h) while not empty?(h)]\bound{h2 }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch6}
\begin{paste}{HeapXmpPageFull6}{HeapXmpPageEmpty6}
\pastebutton{HeapXmpPageFull6}{\hidepaste}
\tab{5}\spadcommand{heapsort(x) == (empty? x => []; cons(extract!(x),heapsort x))\bound{f }}
\indentrel{3}\begin{verbatim}
                                             Type: Void
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty6}
\begin{paste}{HeapXmpPageEmpty6}{HeapXmpPagePatch6}
\pastebutton{HeapXmpPageEmpty6}{\showpaste}
\tab{5}\spadcommand{heapsort(x) == (empty? x => []; cons(extract!(x),heapsort x))\bound{f }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch7}
\begin{paste}{HeapXmpPageFull7}{HeapXmpPageEmpty7}
\pastebutton{HeapXmpPageFull7}{\hidepaste}
\tab{5}\spadcommand{h1 := heap [17,-4,9,-11,2,7,-7]\bound{h1 }}
\indentrel{3}\begin{verbatim}
   (7)  [17,2,9,- 11,- 4,7,- 7]
                                     Type: Heap Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty7}
\begin{paste}{HeapXmpPageEmpty7}{HeapXmpPagePatch7}
\pastebutton{HeapXmpPageEmpty7}{\showpaste}
\tab{5}\spadcommand{h1 := heap [17,-4,9,-11,2,7,-7]\bound{h1 }}
\end{paste}\end{patch}

\begin{patch}{HeapXmpPagePatch8}
\begin{paste}{HeapXmpPageFull8}{HeapXmpPageEmpty8}
\pastebutton{HeapXmpPageFull8}{\hidepaste}
\tab{5}\spadcommand{heapsort h1\free{f }}
\indentrel{3}\begin{verbatim}
   (8)  [17,9,7,2,- 4,- 7,- 11]
                                     Type: List Integer
\end{verbatim}
\indentrel{-3}\end{paste}\end{patch}

\begin{patch}{HeapXmpPageEmpty8}
\begin{paste}{HeapXmpPageEmpty8}{HeapXmpPagePatch8}
\pastebutton{HeapXmpPageEmpty8}{\showpaste}
\tab{5}\spadcommand{heapsort h1\free{f }}
\end{paste}\end{patch}