Created
October 18, 2013 19:53
-
-
Save podviaznikov/7047230 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 sumBTree = function(tree){ | |
if(!tree || tree.length == 0) return 0 | |
return tree[0] + sumBtree(tree[1]) + sumBtree(tree[2]) | |
} | |
var tree = [1, [2, [1], [6]], [3, [1]]] | |
sumBTree(tree) // 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment