JavaScript - Binary Search Tree - inOrderTraverse() function log "undefined" to console window? -


i'm implementing avl tree using javascript, , i'm working inordertraverse() function. problem that: when want log values of nodes console window, shows "undefined" instead.

i've referenced https://gist.github.com/theirondeveloper/6604713 , think there's not difference between code , code i've referenced from.

here js code implementing avl tree: http://jsfiddle.net/nru4t/ or https://dl.dropboxusercontent.com/u/178536659/avl%20tree%20javascript/avltree.js

the result got here: (i run code on chrome)

node 12 added.     avltree.js:205 nodes count = 1    avltree.js:206 undefined          avltree.js:64                    avltree.js:68 node 18 added.     avltree.js:264 nodes count = 2    avltree.js:265 undefined          avltree.js:64 undefined          avltree.js:64                    avltree.js:68                    avltree.js:68 node 20 added.     avltree.js:264 nodes count = 3    avltree.js:265 undefined          avltree.js:64 undefined          avltree.js:64 undefined          avltree.js:64 

please me fix error ... comments appreciated. thank guys lot.

its bug:

in function inordertraverse() have print this.data , not this.value.

inordertraverse: function() {     if(this.left !== null) {         this.left.inordertraverse();     }     console.log(this.data); // <-- here - not this.value     if(this.right !== null) {         this.right.inordertraverse();     }     console.log("\n"); } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -