Skip to content

Instantly share code, notes, and snippets.

@Epotignano
Last active August 29, 2015 14:28
Show Gist options
  • Save Epotignano/ff213efa4fcad0bb77ab to your computer and use it in GitHub Desktop.
Save Epotignano/ff213efa4fcad0bb77ab to your computer and use it in GitHub Desktop.
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