Skip to content

Commit 935fffa

Browse files
committed
description about red black tree
1 parent b0b4fb5 commit 935fffa

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

bst.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,25 @@ <h2>AVL Tree</h2>
431431
<p>It is Self balancing binary search tree. This means in an AVL tree, heights of two child subtrees of any node differ by at most one. If at any time if heights differ more than one, re-balancing is done to restore the height balance property.</p>
432432
<p>Lookup, insertion and deletion all takes O(logn) in average and worst case</p>
433433
</div>
434+
<div id="insertAVL">
435+
<h2>Insert, delete Into AVL</h2>
436+
</div>
434437
<div id="redBlackTree">
435438
<h2>Red Black Tree</h2>
436439
<p><strong>Question:</strong></p>
437-
<p><strong>Answer:</strong></p>
440+
<p><strong>Answer:</strong>A red-black tree is a binary search tree with one extra attribute for each node: the colour, which is either red or black.</p>
441+
<ul>
442+
<li>Every node is either red or black.</li>
443+
<li>Every leaf (NULL) is black.</li>
444+
<li>If a node is red, then both its children are black. However, two black node may be adjacent</li>
445+
<li>Every simple path from a node to a descendant leaf contains the same number of black nodes.</li>
446+
<li>Root node will always be black</li>
447+
</ul>
448+
<img src="images/rb_tree1a.gif" alt="">
449+
<p>ref: <a href="https://www.cs.auckland.ac.nz/software/AlgAnim/red_black.html">Red Black Trees</a></p>
450+
</div>
451+
<div id="redBlackInsertion">
452+
<h2>Insert into Red Black Tree</h2>
438453
</div>
439454
<div>
440455
<h2>Questions list</h2>

images/rb_tree1.gif

1.78 KB
Loading

images/rb_tree1a.gif

2.43 KB
Loading

0 commit comments

Comments
 (0)