Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3a1971f

Browse files
committed
Add comments
1 parentf5427c7 commit3a1971f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎src/data-structures/red-black-tree.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,19 @@
114114
returnnewRoot;
115115
};
116116

117+
/**
118+
* Flip the colors of the both neighbours of given node.
119+
* Complexity O(1).
120+
*/
117121
RBTree.prototype._flipColors=function(node){
118122
node.getLeft().flipColor();
119123
node.getRight().flipColor();
120124
};
121125

126+
/*
127+
* Rotates given node to left.
128+
* Complexity O(1).
129+
*/
122130
RBTree.prototype._rotateLeft=function(node){
123131
varx=node.getRight();
124132
if(x!==null){
@@ -131,6 +139,10 @@
131139
returnx;
132140
};
133141

142+
/*
143+
* Rotates given node to right.
144+
* Complexity O(1).
145+
*/
134146
RBTree.prototype._rotateRight=function(node){
135147
varx=node.getLeft();
136148
if(x!==null){
@@ -143,6 +155,13 @@
143155
returnx;
144156
};
145157

158+
/**
159+
* Gets value by given key.
160+
* Complexity O(log n).
161+
*
162+
*@param {*} key A key to be searched for
163+
*@return {*} A value which will be returned based on the passed key
164+
*/
146165
RBTree.prototype.get=function(key){
147166
returnthis._get(this._root,key);
148167
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp