Last active
August 29, 2015 14:28
-
-
Save Epotignano/ff213efa4fcad0bb77ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var binaryTree = new BTree(values) //values are a collection of values for the node of the binaryThree | |
var recursiveIteration = function(node, numberToSearch) { | |
if(node.value == numberToSearch) return node.position; | |
if(!!node.leftChild.exists() && !!node.rightChild.exists()) return 'Nothing matchs, check other branch' | |
recursiveIteration(node.child) | |
} | |
var searchValInTree = function (numberToSearch, tree ) { //number is the value to search | |
var top = tree.level(1) | |
recursiveIteration(top.leftChild()) | |
recursiveIteration(top.rightChild()) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment