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

Commit 056f119

Browse files
removed zigZag Traverse as It is not part of this pr
1 parent d6533b0 commit 056f119

File tree

1 file changed

+1
-40
lines changed
  • src/_DataStructures_/Trees/BinaryTree

1 file changed

+1
-40
lines changed

‎src/_DataStructures_/Trees/BinaryTree/index.js

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,50 +42,11 @@ class BinaryTree {
4242
preOrder() {
4343
return this.traversePreorder(this.root);
4444
}
45-
traverseZigZag(root){
46-
let arr=[];
47-
48-
let stack1=[];
49-
let stack2=[];
50-
51-
stack1.push(root);
52-
while(stack1.length!==0 || stack2.length!==0)
53-
{
54-
while(stack1.length!==0)
55-
{
56-
let top=stack1[stack1.length-1];
57-
if(top==null)
58-
{
59-
stack1.pop();
60-
continue;
61-
}
62-
63-
arr.push(top.value);
64-
stack2.push(top.leftChild);
65-
stack2.push(top.rightChild);
66-
stack1.pop();
67-
}
68-
while(stack2.length!==0)
69-
{
70-
let top=stack2[stack2.length-1];
71-
if(top==null)
72-
{
73-
stack2.pop();
74-
continue;
75-
}
76-
arr.push(top.value);
77-
stack1.push(top.leftChild);
78-
stack1.push(top.rightChild);
79-
stack2.pop();
80-
}
81-
}
82-
return arr;
83-
}
8445

8546
}
8647

8748
//const bt = new BinaryTree([1, 2, 3, 4, 5, 6]);
8849
// console.log(bt.root);
89-
//console.log(bt.traverseZigZag(bt.root));
50+
//console.log(bt.traversePreorder(bt.root);
9051

9152
module.exports = BinaryTree;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /