Last active
August 29, 2015 14:26
-
-
Save StefanoFiumara/7205e06fbb96a5b0acc0 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
/* | |
* 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