Compare commits
7 commits
a868474177
...
40dd12c50a
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 40dd12c50a | ||
Bruno BELANYI | 8f91d00418 | ||
Bruno BELANYI | 9f39a62771 | ||
Bruno BELANYI | 08959bacfa | ||
Bruno BELANYI | 782d4c94c6 | ||
Bruno BELANYI | 7eb96b11ea | ||
Bruno BELANYI | dec1e79b5c |
|
@ -31,7 +31,7 @@ parent's priority is always higher than any of its children.
|
||||||
## What does it do?
|
## What does it do?
|
||||||
|
|
||||||
By randomizing the priority value of each key at insertion time, we ensure a
|
By randomizing the priority value of each key at insertion time, we ensure a
|
||||||
high likelihood that the tree stays _roughly_ balanced, avoiding degenerating to
|
high likelihook that the tree stays _roughly_ balanced, avoiding degenerating to
|
||||||
unbalanced O(N) height.
|
unbalanced O(N) height.
|
||||||
|
|
||||||
Here's a sample tree created by inserting integers from 0 to 250 into the tree:
|
Here's a sample tree created by inserting integers from 0 to 250 into the tree:
|
||||||
|
@ -41,8 +41,8 @@ Here's a sample tree created by inserting integers from 0 to 250 into the tree:
|
||||||
## Implementation
|
## Implementation
|
||||||
|
|
||||||
I'll be keeping the theme for this [series] by using Python to implement the
|
I'll be keeping the theme for this [series] by using Python to implement the
|
||||||
_Treap_. This leads to somewhat annoying code to handle the rotation process,
|
_Treap_. This leads to somewhat annoying code to handle the `left`/`right` nodes
|
||||||
which is easier to do in C using pointers.
|
which is easier to do in C, using pointers.
|
||||||
|
|
||||||
[series]: {{< ref "/series/cool-algorithms/" >}}
|
[series]: {{< ref "/series/cool-algorithms/" >}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue