From b34f34d8e8c5d19c38fde620522e24e1aab3f0c8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 20 Jul 2024 19:21:47 +0100 Subject: [PATCH] posts: treap: add presentation --- content/posts/2024-07-20-treap/index.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/content/posts/2024-07-20-treap/index.md b/content/posts/2024-07-20-treap/index.md index 30cb2fc..00506c9 100644 --- a/content/posts/2024-07-20-treap/index.md +++ b/content/posts/2024-07-20-treap/index.md @@ -27,3 +27,13 @@ parent's priority is always higher than any of its children. [wiki]: https://en.wikipedia.org/wiki/Treap + +## What does it do? + +By randomizing the priority value of each key at insertion time, we ensure a +high likelihook that the tree stays _roughly_ balanced, avoiding degenerating to +unbalanced O(N) height. + +Here's a sample tree created by inserting integers from 0 to 250 into the tree: + +{{< graphviz file="treap.gv" />}}