Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a8c73a commit f5427c7Copy full SHA for f5427c7
src/data-structures/red-black-tree.js
@@ -66,18 +66,30 @@
66
this._root = null;
67
}
68
69
+ /**
70
+ * Adds value associated with given key.
71
+ * Complexity O(log n)
72
+ */
73
RBTree.prototype.put = function (key, value) {
74
this._root = this._put(key, value, this._root);
75
this._root.setColor(Colors.BLACK);
76
};
77
78
79
+ * Returns true or false depending on whether
80
+ * given node is red.
81
82
RBTree.prototype.isRed = function (node) {
83
if (!node) {
84
return false;
85
86
return node.isRed();
87
88
89
90
+ * Helper function for insertion of given key, value pair
91
+ * into the red-black tree.
92
93
RBTree.prototype._put = function (key, value, node) {
94
var newRoot = node;
95
if (node === null) {
0 commit comments