Skip to content

Instantly share code, notes, and snippets.

@podviaznikov
Created October 18, 2013 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podviaznikov/7047230 to your computer and use it in GitHub Desktop.
Save podviaznikov/7047230 to your computer and use it in GitHub Desktop.
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