Skip to content

Instantly share code, notes, and snippets.

@StefanoFiumara
Last active August 29, 2015 14:26
Show Gist options
  • Save StefanoFiumara/7205e06fbb96a5b0acc0 to your computer and use it in GitHub Desktop.
Save StefanoFiumara/7205e06fbb96a5b0acc0 to your computer and use it in GitHub Desktop.
/*
* Write a program that, given the root node of a tree, returns the sum of all its children.
*
* Example, given the following tree:
* 50
* / \
* 20 30
* / \
* 70 80
* The algorithm should return 250 ( 50 + 20 + 30 + 70 + 80 )
* Each node is represented as follows:
*/
struct Node
{
int nodeValue;
Node leftNode;
Node rightNode;
}
int getSum( Node rootNode )
{
//fill in solution here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment