1// Performs inorder traversal of a tree
2inorder(node)
3{
4 if(node !== null)
5 {
6 this.inorder(node.left);
7 console.log(node.data);
8 this.inorder(node.right);
9 }
10}
11
1// Performs preorder traversal of a tree
2preorder(node)
3{
4 if(node !== null)
5 {
6 console.log(node.data);
7 this.preorder(node.left);
8 this.preorder(node.right);
9 }
10}
11