diff --git a/Uebung08/Paul/IntComparable.java b/Uebung08/Paul/IntComparable.java new file mode 100644 index 0000000..7e2a1f0 --- /dev/null +++ b/Uebung08/Paul/IntComparable.java @@ -0,0 +1,18 @@ +class IntComparable implements Comparable { + private int value; + + IntComparable(int value) { + this.value = value; + } + + @Override + public int compareTo(IntComparable other) { + return Integer.compare(this.value, other.value); + } + + @Override + public String toString() { + // Verwenden Sie eine geeignete String-Darstellung, zum Beispiel den Wert selbst + return Integer.toString(value); + } +} \ No newline at end of file diff --git a/Uebung08/Paul/Main.java b/Uebung08/Paul/Main.java new file mode 100644 index 0000000..c5b0417 --- /dev/null +++ b/Uebung08/Paul/Main.java @@ -0,0 +1,22 @@ +import java.util.Random; + +public class Main { + public static void main(String[] args) { + RBTree rbTree = new RBTree<>(); + Random random = new Random(); + + for (int i = 0; i <= 15; i++) { + int randomValue = random.nextInt(100); + IntComparable key = new IntComparable(randomValue); + + // Füge das Element ein und aktualisiere die DOT-Datei nach jedem Schritt + rbTree.printDOTAfterInsert("output_step_" + i + ".dot", key); + } + + // Jetzt können Sie die DOT-Dateien in SVG umwandeln und anzeigen + // dot -Tsvg output_step_0.dot > output_step_0.svg + // dot -Tsvg output_step_1.dot > output_step_1.svg + // ... + } +} + diff --git a/Uebung08/Paul/RBTree.java b/Uebung08/Paul/RBTree.java new file mode 100644 index 0000000..47b84f0 --- /dev/null +++ b/Uebung08/Paul/RBTree.java @@ -0,0 +1,144 @@ +// RBTree.java + +import java.io.FileWriter; +import java.io.IOException; + +class RBTree> { + + private static final boolean RED = true; + private static final boolean BLACK = false; + private static int step = 0; + + private class Node { + T key; + Node left, right; + boolean color; + + Node(T key, boolean color) { + this.key = key; + this.color = color; + } + } + + private Node root; + + public void insert(T key) { + root = insert(root, key); + root.color = BLACK; // Ensure the root is always black + } + + private Node insert(Node root, T key) { + if (root == null) { + return new Node(key, RED); // New nodes are always red + } + + int cmp = key.compareTo(root.key); + if (cmp < 0) { + root.left = insert(root.left, key); + } else if (cmp > 0) { + root.right = insert(root.right, key); + } else { + // Duplicate key, do not insert + return root; + } + + // Fix any Red-Black tree violations + if (isRed(root.right) && !isRed(root.left)) { + root = rotateLeft(root); + } + if (isRed(root.left) && isRed(root.left.left)) { + root = rotateRight(root); + } + if (isRed(root.left) && isRed(root.right)) { + flipColors(root); + } + + return root; // Return the updated root + } + + private boolean isRed(Node node) { + if (node == null) { + return false; + } + return node.color == RED; + } + + private Node rotateLeft(Node h) { + Node x = h.right; + h.right = x.left; + x.left = h; + x.color = h.color; + h.color = RED; + return x; + } + + private Node rotateRight(Node h) { + Node x = h.left; + h.left = x.right; + x.right = h; + x.color = h.color; + h.color = RED; + return x; + } + + private void flipColors(Node h) { + h.color = RED; + h.left.color = BLACK; + h.right.color = BLACK; + } + + public void printDOTAfterInsert(String filename, T key) { + try (FileWriter writer = new FileWriter(filename)) { + writer.write("digraph G {\n"); + writer.write("\tgraph [ratio=.48];\n"); + writer.write("\tnode [style=filled, color=black, shape=circle, width=.6 \n"); + writer.write("\t\tfontname=Helvetica, fontweight=bold, fontcolor=white, \n"); + writer.write("\t\tfontsize=24, fixedsize=true];\n"); + + root = insert(root, key); // Füge das Element ein und aktualisiere den Baum + printDOTRecursive(root, writer); + + writer.write("}\n"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private void printDOTRecursive(Node node, FileWriter writer) throws IOException { + if (node != null) { + String keyString = node.key.toString().replaceAll("[^a-zA-Z0-9]", "_"); // Ersetze ungültige Zeichen + + // Setze Farben basierend auf der Rot-Schwarz-Eigenschaft + String fillColor = (node.color == RED) ? "red" : "black"; + String fontColor = (node.color == RED) ? "white" : "white"; // Ändern Sie dies, wenn Sie schwarzen Text auf rotem Hintergrund möchten + + // Print current node mit Farbinformationen + writer.write("\t\"" + keyString + "\" [fillcolor=" + fillColor + ", fontcolor=" + fontColor + "];\n"); + + // Print left child + if (node.left != null) { + String leftKeyString = node.left.key.toString().replaceAll("[^a-zA-Z0-9]", "_"); + writer.write("\t\"" + keyString + "\" -> \"" + leftKeyString + "\";\n"); + printDOTRecursive(node.left, writer); + } else { + // Füge ein NIL-Blatt für leere linke Zweige hinzu + String leftNilKeyString = keyString + "_NIL_L"; + writer.write("\t\"" + leftNilKeyString + "\" [shape=plaintext, label=\"NIL\", fontsize=16];\n"); + writer.write("\t\"" + keyString + "\" -> \"" + leftNilKeyString + "\";\n"); + } + + // Print right child + if (node.right != null) { + String rightKeyString = node.right.key.toString().replaceAll("[^a-zA-Z0-9]", "_"); + writer.write("\t\"" + keyString + "\" -> \"" + rightKeyString + "\";\n"); + printDOTRecursive(node.right, writer); + } else { + // Füge ein NIL-Blatt für leere rechte Zweige hinzu + String rightNilKeyString = keyString + "_NIL_R"; + writer.write("\t\"" + rightNilKeyString + "\" [shape=plaintext, label=\"NIL\", fontsize=16];\n"); + writer.write("\t\"" + keyString + "\" -> \"" + rightNilKeyString + "\";\n"); + } + } + } +} + diff --git a/bin/IntComparable.class b/bin/IntComparable.class new file mode 100644 index 0000000..5f07088 Binary files /dev/null and b/bin/IntComparable.class differ diff --git a/bin/Main.class b/bin/Main.class new file mode 100644 index 0000000..52d53e6 Binary files /dev/null and b/bin/Main.class differ diff --git a/bin/RBTree$Node.class b/bin/RBTree$Node.class new file mode 100644 index 0000000..64a9b55 Binary files /dev/null and b/bin/RBTree$Node.class differ diff --git a/bin/RBTree.class b/bin/RBTree.class new file mode 100644 index 0000000..19dd46e Binary files /dev/null and b/bin/RBTree.class differ diff --git a/output.svg b/output.svg new file mode 100644 index 0000000..f45c4ff Binary files /dev/null and b/output.svg differ diff --git a/output_step_0.dot b/output_step_0.dot new file mode 100644 index 0000000..2ffc6d5 --- /dev/null +++ b/output_step_0.dot @@ -0,0 +1,11 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "56" -> "56_NIL_L"; + "56_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "56" -> "56_NIL_R"; +} diff --git a/output_step_1.dot b/output_step_1.dot new file mode 100644 index 0000000..45d7147 --- /dev/null +++ b/output_step_1.dot @@ -0,0 +1,15 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "33"; + "33" [fillcolor=red, fontcolor=white]; + "33_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_L"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "56" -> "56_NIL_R"; +} diff --git a/output_step_10.dot b/output_step_10.dot new file mode 100644 index 0000000..0f81282 --- /dev/null +++ b/output_step_10.dot @@ -0,0 +1,51 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=red, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_L"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_11.dot b/output_step_11.dot new file mode 100644 index 0000000..df8becb --- /dev/null +++ b/output_step_11.dot @@ -0,0 +1,55 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=red, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11" -> "8"; + "8" [fillcolor=red, fontcolor=white]; + "8_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_L"; + "8_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_R"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_L"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_12.dot b/output_step_12.dot new file mode 100644 index 0000000..df8becb --- /dev/null +++ b/output_step_12.dot @@ -0,0 +1,55 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=red, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11" -> "8"; + "8" [fillcolor=red, fontcolor=white]; + "8_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_L"; + "8_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_R"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_L"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_13.dot b/output_step_13.dot new file mode 100644 index 0000000..488a727 --- /dev/null +++ b/output_step_13.dot @@ -0,0 +1,59 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=red, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11" -> "8"; + "8" [fillcolor=red, fontcolor=white]; + "8_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_L"; + "8_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_R"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_L"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "64"; + "64" [fillcolor=black, fontcolor=white]; + "64" -> "63"; + "63" [fillcolor=red, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "64_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "64" -> "64_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_14.dot b/output_step_14.dot new file mode 100644 index 0000000..52b6447 --- /dev/null +++ b/output_step_14.dot @@ -0,0 +1,63 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=red, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11" -> "8"; + "8" [fillcolor=red, fontcolor=white]; + "8_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_L"; + "8_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_R"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19" -> "18"; + "18" [fillcolor=red, fontcolor=white]; + "18_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "18" -> "18_NIL_L"; + "18_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "18" -> "18_NIL_R"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "64"; + "64" [fillcolor=black, fontcolor=white]; + "64" -> "63"; + "63" [fillcolor=red, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "64_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "64" -> "64_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_15.dot b/output_step_15.dot new file mode 100644 index 0000000..9b639e1 --- /dev/null +++ b/output_step_15.dot @@ -0,0 +1,67 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=red, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=black, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11" -> "8"; + "8" [fillcolor=red, fontcolor=white]; + "8_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_L"; + "8_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "8" -> "8_NIL_R"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15" -> "19"; + "19" [fillcolor=black, fontcolor=white]; + "19" -> "18"; + "18" [fillcolor=red, fontcolor=white]; + "18_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "18" -> "18_NIL_L"; + "18_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "18" -> "18_NIL_R"; + "19_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "19" -> "19_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=black, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33" -> "49"; + "49" [fillcolor=black, fontcolor=white]; + "49_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "49" -> "49_NIL_L"; + "49_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "49" -> "49_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "64"; + "64" [fillcolor=black, fontcolor=white]; + "64" -> "63"; + "63" [fillcolor=red, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "64_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "64" -> "64_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +} diff --git a/output_step_2.dot b/output_step_2.dot new file mode 100644 index 0000000..91e649e --- /dev/null +++ b/output_step_2.dot @@ -0,0 +1,19 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_L"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; +} diff --git a/output_step_3.dot b/output_step_3.dot new file mode 100644 index 0000000..96f7471 --- /dev/null +++ b/output_step_3.dot @@ -0,0 +1,23 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "25"; + "25" [fillcolor=red, fontcolor=white]; + "25_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "25" -> "25_NIL_L"; + "25_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "25" -> "25_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; +} diff --git a/output_step_4.dot b/output_step_4.dot new file mode 100644 index 0000000..8b0be62 --- /dev/null +++ b/output_step_4.dot @@ -0,0 +1,27 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=red, fontcolor=white]; + "25" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_L"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; +} diff --git a/output_step_5.dot b/output_step_5.dot new file mode 100644 index 0000000..6227992 --- /dev/null +++ b/output_step_5.dot @@ -0,0 +1,31 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=red, fontcolor=white]; + "25" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_L"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "89"; + "89" [fillcolor=black, fontcolor=white]; + "89" -> "63"; + "63" [fillcolor=red, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; +} diff --git a/output_step_6.dot b/output_step_6.dot new file mode 100644 index 0000000..ec102d9 --- /dev/null +++ b/output_step_6.dot @@ -0,0 +1,35 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=red, fontcolor=white]; + "25" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "89"; + "89" [fillcolor=black, fontcolor=white]; + "89" -> "63"; + "63" [fillcolor=red, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; +} diff --git a/output_step_7.dot b/output_step_7.dot new file mode 100644 index 0000000..d0d7112 --- /dev/null +++ b/output_step_7.dot @@ -0,0 +1,39 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "11"; + "11" [fillcolor=black, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "89"; + "89" [fillcolor=black, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; +} diff --git a/output_step_8.dot b/output_step_8.dot new file mode 100644 index 0000000..9b7826f --- /dev/null +++ b/output_step_8.dot @@ -0,0 +1,43 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=black, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=red, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "15" -> "15_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "89"; + "89" [fillcolor=black, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; +} diff --git a/output_step_9.dot b/output_step_9.dot new file mode 100644 index 0000000..a20f5e0 --- /dev/null +++ b/output_step_9.dot @@ -0,0 +1,47 @@ +digraph G { + graph [ratio=.48]; + node [style=filled, color=black, shape=circle, width=.6 + fontname=Helvetica, fontweight=bold, fontcolor=white, + fontsize=24, fixedsize=true]; + "56" [fillcolor=red, fontcolor=white]; + "56" -> "25"; + "25" [fillcolor=black, fontcolor=white]; + "25" -> "15"; + "15" [fillcolor=black, fontcolor=white]; + "15" -> "11"; + "11" [fillcolor=red, fontcolor=white]; + "11_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_L"; + "11_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "11" -> "11_NIL_R"; + "15_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "15" -> "15_NIL_R"; + "25" -> "33"; + "33" [fillcolor=black, fontcolor=white]; + "33" -> "27"; + "27" [fillcolor=red, fontcolor=white]; + "27_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_L"; + "27_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "27" -> "27_NIL_R"; + "33_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "33" -> "33_NIL_R"; + "56" -> "69"; + "69" [fillcolor=black, fontcolor=white]; + "69" -> "63"; + "63" [fillcolor=black, fontcolor=white]; + "63_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_L"; + "63_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "63" -> "63_NIL_R"; + "69" -> "98"; + "98" [fillcolor=black, fontcolor=white]; + "98" -> "89"; + "89" [fillcolor=red, fontcolor=white]; + "89_NIL_L" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_L"; + "89_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "89" -> "89_NIL_R"; + "98_NIL_R" [shape=plaintext, label="NIL", fontsize=16]; + "98" -> "98_NIL_R"; +}