- <svg xmlns="http://www.w3.org/2000/svg" width="990" height="340" viewBox="0 0 990 340">
- <style>.t{font:16px sans-serif;fill:#1f2937}.s{font:13px sans-serif;fill:#475569}.n{fill:#fff;stroke:#2563eb;stroke-width:3}.x{fill:#fef3c7;stroke:#d97706;stroke-width:4}.e{stroke:#64748b;stroke-width:3}.arrow{stroke:#16a34a;stroke-width:4;fill:none}</style>
- <rect width="990" height="340" fill="white"/><text x="30" y="33" class="t" font-weight="bold">Splay 每轮只看 x、父亲 p、祖父 g 的相对方向</text>
- <g transform="translate(35 65)"><text x="65" y="0" class="t">zig:p 是根</text><line x1="70" y1="42" x2="70" y2="105" class="e"/><circle cx="70" cy="42" r="21" class="n"/><circle cx="70" cy="115" r="21" class="x"/><text x="70" y="48" class="t" text-anchor="middle">p</text><text x="70" y="121" class="t" text-anchor="middle">x</text><path d="M135 90 h75" class="arrow"/><path d="M210 90 l-12 -7 v14z" fill="#16a34a"/><text x="125" y="145" class="s">rotate(x) 一次</text></g>
- <g transform="translate(345 65)"><text x="30" y="0" class="t">zig-zig:同向</text><line x1="75" y1="42" x2="75" y2="100" class="e"/><line x1="75" y1="100" x2="75" y2="160" class="e"/><circle cx="75" cy="42" r="20" class="n"/><circle cx="75" cy="100" r="20" class="n"/><circle cx="75" cy="160" r="20" class="x"/><g class="t" text-anchor="middle"><text x="75" y="48">g</text><text x="75" y="106">p</text><text x="75" y="166">x</text></g><path d="M145 100 h85" class="arrow"/><path d="M230 100 l-12 -7 v14z" fill="#16a34a"/><text x="20" y="210" class="s">先 rotate(p),再 rotate(x)</text></g>
- <g transform="translate(675 65)"><text x="20" y="0" class="t">zig-zag:异向</text><line x1="70" y1="42" x2="35" y2="100" class="e"/><line x1="35" y1="100" x2="85" y2="160" class="e"/><circle cx="70" cy="42" r="20" class="n"/><circle cx="35" cy="100" r="20" class="n"/><circle cx="85" cy="160" r="20" class="x"/><g class="t" text-anchor="middle"><text x="70" y="48">g</text><text x="35" y="106">p</text><text x="85" y="166">x</text></g><path d="M145 100 h85" class="arrow"/><path d="M230 100 l-12 -7 v14z" fill="#16a34a"/><text x="12" y="210" class="s">rotate(x) 连续两次</text></g>
- <text x="35" y="305" class="s">黄色 x 是目标;“同向/异向”只看 x 相对 p 与 p 相对 g 的左右方向,不看键的大小。</text>
- </svg>
|