1
0

00-文艺-02-双哨兵与区间暴露.svg 2.3 KB

1234567891011121314
  1. <svg xmlns="http://www.w3.org/2000/svg" width="960" height="330" viewBox="0 0 960 330">
  2. <style>.t{font:16px sans-serif;fill:#1f2937}.s{font:13px sans-serif;fill:#475569}.card{fill:#fff;stroke:#2563eb;stroke-width:3}.sent{fill:#e2e8f0;stroke:#475569;stroke-width:3}.mid{fill:#fef3c7;stroke:#d97706;stroke-width:4}.e{stroke:#64748b;stroke-width:3}.tree{fill:#dcfce7;stroke:#16a34a;stroke-width:3}</style>
  3. <rect width="960" height="330" fill="white"/><text x="32" y="34" class="t" font-weight="bold">双哨兵:先用 A 与 F 夹住 B..E,再把 B..E 变成 F 的左子树</text>
  4. <text x="45" y="78" class="s">完整中序:</text>
  5. <g transform="translate(130 55)"><rect x="0" y="0" width="58" height="42" rx="7" class="sent"/><rect x="65" y="0" width="58" height="42" rx="7" class="card"/><rect x="130" y="0" width="58" height="42" rx="7" class="mid"/><rect x="195" y="0" width="58" height="42" rx="7" class="mid"/><rect x="260" y="0" width="58" height="42" rx="7" class="mid"/><rect x="325" y="0" width="58" height="42" rx="7" class="mid"/><rect x="390" y="0" width="58" height="42" rx="7" class="card"/><rect x="455" y="0" width="58" height="42" rx="7" class="sent"/>
  6. <g class="t" text-anchor="middle"><text x="29" y="27">L</text><text x="94" y="27">A</text><text x="159" y="27">B</text><text x="224" y="27">C</text><text x="289" y="27">D</text><text x="354" y="27">E</text><text x="419" y="27">F</text><text x="484" y="27">R</text></g></g>
  7. <text x="205" y="125" class="s">x=kth(l)=A</text><text x="510" y="125" class="s">y=kth(r+2)=F</text>
  8. <path d="M340 145 C370 155 395 160 430 165" stroke="#16a34a" stroke-width="4" fill="none"/><path d="M430 165 l-14 -9 v18z" fill="#16a34a"/>
  9. <text x="350" y="150" class="s">splay x 到根,再让 y 成为 x 的右儿子</text>
  10. <circle cx="300" cy="235" r="27" class="card"/><circle cx="620" cy="235" r="27" class="card"/><rect x="410" y="220" width="125" height="55" rx="9" class="tree"/>
  11. <g class="e"><line x1="327" y1="235" x2="410" y2="247"/><line x1="535" y1="247" x2="593" y2="235"/></g>
  12. <g class="t" text-anchor="middle"><text x="300" y="241">A=x</text><text x="472" y="244">B,C,D,E</text><text x="472" y="263" class="s">y.left</text><text x="620" y="241">F=y</text></g>
  13. <text x="250" y="310" class="s">目标区间不再散在多个分支,而成为可整体打 rev、读 sum 的一棵子树。</text>
  14. </svg>