| 123456789101112 |
- <svg xmlns="http://www.w3.org/2000/svg" width="940" height="315" viewBox="0 0 940 315">
- <style>.t{font:16px sans-serif;fill:#1f2937}.s{font:13px sans-serif;fill:#475569}.n{fill:#fff;stroke:#2563eb;stroke-width:3}.tag{fill:#fef3c7;stroke:#d97706;stroke-width:3}.e{stroke:#64748b;stroke-width:3}.a{stroke:#dc2626;stroke-width:4;fill:none}</style>
- <rect width="940" height="315" fill="white"/><text x="32" y="34" class="t" font-weight="bold">rev Lazy:不逐项翻转,只交换根的左右孩子并翻转一位标记</text>
- <g class="e"><line x1="200" y1="100" x2="115" y2="205"/><line x1="200" y1="100" x2="285" y2="205"/></g><circle cx="200" cy="100" r="28" class="n"/><circle cx="115" cy="205" r="28" class="n"/><circle cx="285" cy="205" r="28" class="n"/>
- <g class="t" text-anchor="middle"><text x="200" y="106">mid</text><text x="115" y="211">左段</text><text x="285" y="211">右段</text></g>
- <rect x="160" y="45" width="80" height="30" rx="7" class="tag"/><text x="200" y="66" class="t" text-anchor="middle">rev ^= 1</text>
- <path d="M355 155 H505" class="a"/><path d="M505 155 l-14 -8 v16z" fill="#dc2626"/><text x="378" y="132" class="s">swap(left,right)</text>
- <g class="e"><line x1="680" y1="100" x2="765" y2="205"/><line x1="680" y1="100" x2="595" y2="205"/></g><circle cx="680" cy="100" r="28" class="n"/><circle cx="595" cy="205" r="28" class="n"/><circle cx="765" cy="205" r="28" class="n"/>
- <g class="t" text-anchor="middle"><text x="680" y="106">mid</text><text x="595" y="211">右段</text><text x="765" y="211">左段</text></g>
- <rect x="640" y="45" width="80" height="30" rx="7" class="tag"/><text x="680" y="66" class="t" text-anchor="middle">rev ^= 1</text>
- <text x="55" y="285" class="s">下一次真正走入孩子前再 push;两次翻转会抵消,故标记用 XOR/布尔取反复合。</text>
- </svg>
|