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 3f69eba commit f8d360aCopy full SHA for f8d360a
tuts/data-structures/binary-search-tree/index.js
@@ -28,19 +28,17 @@ const deleteNode = (root, value) => {
28
} else if (value > root.value) {
29
root.right = deleteNode(root.right, value);
30
} else {
31
- if (root.left === null && root.right === null) {
32
- return null;
33
- } else if (root.left === null && root.right) {
+ if (root.left === null) {
34
return root.right;
35
- } else if (root.right === null&&root.left) {
+ } else if (root.right === null) {
36
return root.left;
37
38
let nextHighestNode = root.right;
39
- while (nextHighestNode&&nextHighestNode.left) {
+ while (nextHighestNode.left) {
40
nextHighestNode = nextHighestNode.left;
41
}
42
root.value = nextHighestNode.value;
43
- root.right = deleteNode(nextHighestNode, nextHighestNode.value);
+ root.right = deleteNode(root.right, nextHighestNode.value);
44
45
46
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments