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
|
<svg xmlns="http://www.w3.org/2000/svg" width="1920" height="1080" viewBox="0 0 1920 1080">
<defs><pattern id="hatch" width="20" height="20" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="5" height="20" fill="#3a4a8a"/></pattern><pattern id="hazard" width="24" height="24" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="24" height="24" fill="#050a24"/><rect width="12" height="24" fill="#ff6a4a"/></pattern></defs>
<rect width="1920" height="1080" fill="#0a1030"/>
<text x="64.0" y="81.0" font-family="Go Medium" font-size="28" fill="#9aa6d9" xml:space="preserve">Insertion sort</text>
<text x="275.1 290.1 305.1 320.1 335.1 350.1 365.1 380.1" y="81.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">sort.c:6</text>
<text x="1790.9" y="80.0" font-family="Go Medium" font-size="22" fill="#6a7ab8" xml:space="preserve">kernel</text>
<rect x="1767.9" y="66.0" width="14.0" height="14.0" fill="none" stroke="#3a4a8a" stroke-width="2"/>
<text x="1646.4" y="80.0" font-family="Go Medium" font-size="22" fill="#6a7ab8" xml:space="preserve">memory</text>
<rect x="1623.4" y="66.0" width="14.0" height="14.0" fill="none" stroke="#3a4a8a" stroke-width="2"/>
<text x="1547.1" y="80.0" font-family="Go Medium" font-size="22" fill="#6a7ab8" xml:space="preserve">cpu</text>
<rect x="1524.1" y="66.0" width="14.0" height="14.0" fill="none" stroke="#3a4a8a" stroke-width="2"/>
<text x="1416.1" y="80.0" font-family="Go Medium" font-size="22" fill="#eee6d2" xml:space="preserve">source</text>
<rect x="1392.1" y="65.0" width="16.0" height="16.0" fill="#e8c46a"/>
<line x1="64.0" y1="104.0" x2="1856.0" y2="104.0" stroke="#3a4a8a" stroke-width="2"/>
<rect x="64.0" y="120.0" width="1792.0" height="48.0" fill="#16245f"/>
<rect x="65.0" y="121.0" width="1790.0" height="406.0" fill="none" stroke="#9aa6d9" stroke-width="2"/>
<line x1="64.0" y1="168.0" x2="1856.0" y2="168.0" stroke="#9aa6d9" stroke-width="2"/>
<rect x="78.0" y="134.0" width="20.0" height="20.0" fill="#e8c46a"/>
<text x="112.0" y="154.0" font-family="Go Medium" font-size="28" fill="#eee6d2" xml:space="preserve">a</text>
<text x="1840.0" y="152.0" font-family="Go" font-size="22" fill="#6a7ab8" xml:space="preserve" text-anchor="end">int a[8]</text>
<rect x="288.0" y="308.0" width="166.0" height="132.0" fill="#16245f"/>
<text x="302.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">0</text>
<text x="353.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">4</text>
<rect x="456.0" y="308.0" width="166.0" height="132.0" fill="#16245f"/>
<text x="470.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">1</text>
<text x="521.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">9</text>
<rect x="624.0" y="308.0" width="166.0" height="132.0" fill="#16245f"/>
<text x="638.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">2</text>
<text x="671.0 707.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">17</text>
<rect x="792.0" y="308.0" width="166.0" height="132.0" fill="#1c4652"/>
<rect x="794.0" y="310.0" width="162.0" height="128.0" fill="none" stroke="#6fd6e6" stroke-width="4"/>
<text x="806.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#9aa6d9" xml:space="preserve">3</text>
<rect x="883.0" y="318.0" width="65.0" height="36.0" fill="#0a1030"/>
<text x="893.0 908.0 923.0" y="345.0" font-family="JetBrains Mono NL" font-size="25" fill="#eee6d2" xml:space="preserve" font-weight="bold">j-1</text>
<text x="839.0 875.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#6a7ab8" xml:space="preserve">31</text>
<rect x="960.0" y="308.0" width="166.0" height="132.0" fill="#1c4652"/>
<rect x="962.0" y="310.0" width="162.0" height="128.0" fill="none" stroke="#6fd6e6" stroke-width="4"/>
<text x="974.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#9aa6d9" xml:space="preserve">4</text>
<rect x="1081.0" y="318.0" width="35.0" height="36.0" fill="#0a1030"/>
<text x="1091.0" y="345.0" font-family="JetBrains Mono NL" font-size="25" fill="#eee6d2" xml:space="preserve" font-weight="bold">j</text>
<text x="1007.0 1043.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#6a7ab8" xml:space="preserve">12</text>
<rect x="1128.0" y="308.0" width="166.0" height="132.0" fill="#5a2218"/>
<rect x="1128.0" y="434.0" width="166.0" height="6.0" fill="#ff6a4a"/>
<text x="1142.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#9aa6d9" xml:space="preserve">5</text>
<rect x="1249.0" y="318.0" width="35.0" height="36.0" fill="#0a1030"/>
<text x="1259.0" y="345.0" font-family="JetBrains Mono NL" font-size="25" fill="#eee6d2" xml:space="preserve" font-weight="bold">i</text>
<text x="1175.0 1211.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">26</text>
<rect x="1296.0" y="308.0" width="166.0" height="132.0" fill="#16245f"/>
<text x="1310.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">6</text>
<text x="1361.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">5</text>
<rect x="1464.0" y="308.0" width="166.0" height="132.0" fill="#16245f"/>
<text x="1478.0" y="342.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">7</text>
<text x="1511.0 1547.0" y="413.6" font-family="JetBrains Mono NL" font-size="60" fill="#eee6d2" xml:space="preserve">20</text>
<rect x="882.0" y="179.0" width="156.0" height="44.0" fill="none" stroke="#9aa6d9" stroke-width="2"/>
<text x="897.0 915.0 933.0 951.0 969.0 987.0 1005.0" y="211.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">31 > 12</text>
<text x="1055.0" y="209.6" font-family="Go" font-size="24" fill="#9aa6d9" xml:space="preserve">so they trade places</text>
<path d="M876.0,304 Q960.0,212.0 1044.0,304" fill="none" stroke="#9aa6d9" stroke-width="3" stroke-linejoin="round" stroke-linecap="butt"/>
<path d="M1044.0,304.0 L1028.0,296.9 L1038.4,287.5 Z" fill="#9aa6d9"/>
<rect x="886.5" y="231.6" width="100.0" height="60.0" fill="#0a1030"/>
<rect x="888.0" y="233.1" width="97.0" height="57.0" fill="none" stroke="#fff8e8" stroke-width="3"/>
<text x="909.5 936.5" y="277.8" font-family="JetBrains Mono NL" font-size="45" fill="#fff8e8" xml:space="preserve" font-weight="bold">31</text>
<path d="M1044.0,444 Q960.0,536.0 876.0,444" fill="none" stroke="#9aa6d9" stroke-width="3" stroke-linejoin="round" stroke-linecap="butt"/>
<path d="M876.0,444.0 L892.0,451.1 L881.6,460.5 Z" fill="#9aa6d9"/>
<rect x="933.5" y="456.4" width="100.0" height="60.0" fill="#0a1030"/>
<rect x="935.0" y="457.9" width="97.0" height="57.0" fill="none" stroke="#fff8e8" stroke-width="3"/>
<text x="956.5 983.5" y="502.6" font-family="JetBrains Mono NL" font-size="45" fill="#fff8e8" xml:space="preserve" font-weight="bold">12</text>
<rect x="64.0" y="552.0" width="1032.0" height="48.0" fill="#16245f"/>
<rect x="65.0" y="553.0" width="1030.0" height="334.0" fill="none" stroke="#3a4a8a" stroke-width="2"/>
<line x1="64.0" y1="600.0" x2="1096.0" y2="600.0" stroke="#3a4a8a" stroke-width="2"/>
<rect x="79.0" y="567.0" width="18.0" height="18.0" fill="none" stroke="#6a7ab8" stroke-width="2"/>
<text x="112.0" y="586.0" font-family="Go Medium" font-size="28" fill="#9aa6d9" xml:space="preserve">sort.c</text>
<text x="112.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#6a7ab8" xml:space="preserve">3</text>
<text x="156.0 174.0 192.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#c0dcff" xml:space="preserve" font-weight="bold">for</text>
<text x="228.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">(</text>
<text x="246.0 264.0 282.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#c0dcff" xml:space="preserve" font-weight="bold">int</text>
<text x="318.0 336.0 354.0 372.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">i = </text>
<text x="390.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#b5e8c8" xml:space="preserve">1</text>
<text x="408.0 426.0 444.0 462.0 480.0 498.0 516.0 534.0 552.0 570.0 588.0 606.0 624.0 642.0 660.0" y="650.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">; i < n; i++) {</text>
<text x="112.0" y="698.8" font-family="JetBrains Mono NL" font-size="30" fill="#6a7ab8" xml:space="preserve">4</text>
<text x="228.0 246.0 264.0" y="698.8" font-family="JetBrains Mono NL" font-size="30" fill="#c0dcff" xml:space="preserve" font-weight="bold">int</text>
<text x="300.0 318.0 336.0 354.0 372.0 390.0" y="698.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">j = i;</text>
<rect x="66.0" y="714.0" width="6.0" height="44.0" fill="#ae9350"/>
<text x="112.0" y="746.8" font-family="JetBrains Mono NL" font-size="30" fill="#6a7ab8" xml:space="preserve">5</text>
<text x="228.0 246.0 264.0 282.0 300.0" y="746.8" font-family="JetBrains Mono NL" font-size="30" fill="#c0dcff" xml:space="preserve" font-weight="bold">while</text>
<text x="336.0 354.0 372.0 390.0 408.0" y="746.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">(j > </text>
<text x="426.0" y="746.8" font-family="JetBrains Mono NL" font-size="30" fill="#b5e8c8" xml:space="preserve">0</text>
<text x="462.0 480.0 498.0 516.0 534.0 552.0 570.0 588.0 606.0 624.0 642.0 660.0 678.0 696.0 714.0 732.0 750.0 768.0 786.0" y="746.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">&& a[j-1] > a[j]) {</text>
<rect x="66.0" y="762.0" width="1028.0" height="44.0" fill="#4a3d1c"/>
<rect x="66.0" y="762.0" width="74.0" height="44.0" fill="#e8c46a"/>
<text x="112.0" y="794.8" font-family="JetBrains Mono NL" font-size="30" fill="#050a24" xml:space="preserve" font-weight="bold">6</text>
<text x="300.0 318.0 336.0 354.0 372.0 390.0 408.0 426.0 444.0 462.0 480.0 498.0 516.0 534.0 552.0 570.0 588.0 606.0 624.0 642.0 660.0" y="794.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">swap(&a[j-1], &a[j]);</text>
<rect x="66.0" y="810.0" width="6.0" height="44.0" fill="#746235"/>
<text x="112.0" y="842.8" font-family="JetBrains Mono NL" font-size="30" fill="#6a7ab8" xml:space="preserve">7</text>
<text x="300.0 318.0 336.0 354.0" y="842.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">j--;</text>
<rect x="1128.0" y="552.0" width="728.0" height="48.0" fill="#16245f"/>
<rect x="1129.0" y="553.0" width="726.0" height="334.0" fill="none" stroke="#3a4a8a" stroke-width="2"/>
<line x1="1128.0" y1="600.0" x2="1856.0" y2="600.0" stroke="#3a4a8a" stroke-width="2"/>
<rect x="1143.0" y="567.0" width="18.0" height="18.0" fill="none" stroke="#6a7ab8" stroke-width="2"/>
<text x="1176.0" y="586.0" font-family="Go Medium" font-size="28" fill="#9aa6d9" xml:space="preserve">locals</text>
<text x="1840.0" y="584.0" font-family="Go" font-size="22" fill="#6a7ab8" xml:space="preserve" text-anchor="end">of sort()</text>
<text x="1152.0" y="645.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">i</text>
<text x="1212.0 1227.0 1242.0" y="644.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">int</text>
<text x="1340.0" y="645.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">5</text>
<text x="1152.0" y="701.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">j</text>
<text x="1212.0 1227.0 1242.0" y="700.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">int</text>
<rect x="1324.0" y="668.0" width="76.0" height="46.0" fill="#5a2218"/>
<rect x="1324.0" y="708.0" width="76.0" height="6.0" fill="#ff6a4a"/>
<text x="1340.0" y="701.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">4</text>
<text x="1152.0" y="757.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">n</text>
<text x="1212.0 1227.0 1242.0" y="756.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">int</text>
<text x="1340.0" y="757.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">8</text>
<text x="1152.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#eee6d2" xml:space="preserve">a</text>
<text x="1212.0 1227.0 1242.0 1257.0 1272.0" y="812.0" font-family="JetBrains Mono NL" font-size="25" fill="#6a7ab8" xml:space="preserve">int *</text>
<text x="1340.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">7</text>
<text x="1358.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">f</text>
<text x="1376.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">f</text>
<text x="1394.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">d</text>
<text x="1412.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">3</text>
<text x="1430.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">a</text>
<text x="1448.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">2</text>
<text x="1466.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">c</text>
<text x="1484.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">1</text>
<text x="1502.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">e</text>
<text x="1520.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">2</text>
<text x="1538.0" y="813.8" font-family="JetBrains Mono NL" font-size="30" fill="#f2d675" xml:space="preserve">0</text>
<text x="1576.0" y="811.6" font-family="Go" font-size="24" fill="#9aa6d9" xml:space="preserve">where a[0] is</text>
<text x="64.0" y="964.0" font-size="40" xml:space="preserve"><tspan font-family="Go" font-weight="normal" fill="#eee6d2">While the one on the left is larger, they trade places,</tspan></text>
<text x="64.0" y="1018.0" font-size="40" xml:space="preserve"><tspan font-family="Go" font-weight="normal" fill="#eee6d2">and </tspan><tspan font-family="JetBrains Mono NL" font-weight="normal" fill="#eee6d2" font-size="35">j</tspan><tspan font-family="Go" font-weight="normal" fill="#eee6d2"> follows the smaller value down.</tspan></text>
</svg>
|