summaryrefslogtreecommitdiff
path: root/src/03/08/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/03/08/README.md')
-rw-r--r--src/03/08/README.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/03/08/README.md b/src/03/08/README.md
index 163f487..b2eecc3 100644
--- a/src/03/08/README.md
+++ b/src/03/08/README.md
@@ -1 +1,45 @@
+
Prove that a binary tree with `k` leaves has height at least `log k`.
+
+```plaintext
+tree = h(k)
+assert(height(tree) == log k)
+
+for each positive natural number this is true.
+```
+
+```c
+BTree *h(int k)
+{
+ BTree *tree = rb_tree_initialize();
+ // assert(true == true);
+ // generate k leaves with random data
+ return tree;
+}
+
+for (int k = 0; k < 1000; k++) {
+ assert(height(h(k)) >= log(k))
+}
+```
+
+
+```plaintext
+n: 3
+h: 3
+
+(x)
+ \
+ (y)
+ \
+ (z)
+
+n: 3
+k: 2
+h: 2
+
+ (y)
+ / \
+(x) (z)
+
+2^x == 2
+```