mirror of
https://github.com/mfocko/blog.git
synced 2025-05-08 20:32:57 +02:00
fix: revert the ‹ThemedSVG› shite
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
b5fbddb8c9
commit
85cda31779
3 changed files with 32 additions and 30 deletions
ib002/08-rb-trees
|
@ -10,8 +10,6 @@ last_update:
|
|||
date: 2023-06-10
|
||||
---
|
||||
|
||||
import ThemedSVG from "@site/src/components/ThemedSVG";
|
||||
|
||||
## Introduction
|
||||
|
||||
Have you ever thought about the red-black tree rules in more depth? Why are they
|
||||
|
@ -57,10 +55,8 @@ my child would be colored red.
|
|||
Example of a red-black tree that keeps count of black nodes on paths to the
|
||||
leaves follows:
|
||||
|
||||
<ThemedSVG
|
||||
source="/files/ib002/rb-trees/rules/rb_height"
|
||||
alt="Red-black tree with black height"
|
||||
/>
|
||||

|
||||

|
||||
|
||||
We mark the _black heights_ in superscript. You can see that all leaves have the
|
||||
black height equal to $1$. Let's take a look at some of the interesting cases:
|
||||
|
@ -144,15 +140,15 @@ accordingly.
|
|||
|
||||
| Usual algorithm with black root | Allowing red root |
|
||||
| :-----------------------------: | :---------------: |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_0" alt="1ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_0" alt="1ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_1" alt="2ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_1" alt="2ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_2" alt="3ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_2" alt="3ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_3" alt="4ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_3" alt="4ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_4" alt="5ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_4" alt="5ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_5" alt="6ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_5" alt="6ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_6" alt="7ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_6" alt="7ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_7" alt="8ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_7" alt="8ª insertion" /> |
|
||||
| <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/br_8" alt="9ª insertion" /> | <ThemedSVG source="/files/ib002/rb-trees/rules/red-root/rr_8" alt="9ª insertion" /> |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 3ª Every leaf (`nil`) is black.
|
||||
|
||||
|
@ -161,7 +157,8 @@ some other way? Let's go through some of the possible ways I can look at this an
|
|||
how would they affect the other rules and balancing.
|
||||
|
||||
We will experiment with the following tree:
|
||||
<ThemedSVG source="/files/ib002/rb-trees/rules/rb" />
|
||||

|
||||

|
||||
|
||||
We should start by counting the black nodes from root to the `nil` leaves based
|
||||
on the rules. We have multiple similar paths, so we will pick only the interesting
|
||||
|
@ -234,11 +231,17 @@ import TabItem from '@theme/TabItem';
|
|||
|
||||
<Tabs>
|
||||
<TabItem value="enforcing" label="Enforcing this rule">
|
||||
<ThemedSVG source="/files/ib002/rb-trees/rules/red-node-black-children/correct" />
|
||||
|
||||

|
||||

|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem value="omitting" label="Omitting this rule">
|
||||
<ThemedSVG source="/files/ib002/rb-trees/rules/red-node-black-children/incorrect" />
|
||||
|
||||

|
||||

|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue