File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ /* ***********************************************************
2+
3+ Following is the structure for the TreeNode class
4+
5+ template <typename T>
6+ class TreeNode {
7+ public:
8+ T data;
9+ vector<TreeNode<T>*> children;
10+
11+ TreeNode(T data) {
12+ this->data = data;
13+ }
14+
15+ ~TreeNode() {
16+ for (int i = 0; i < children.size(); i++) {
17+ delete children[i];
18+ }
19+ }
20+ };
21+
22+ ************************************************************/
23+
24+ int getLargeNodeCount (TreeNode<int >* root, int x) {
25+ // Write your code here
26+ int count = 0 ;
27+ for (int i=0 ;i<root->children .size ();i++){
28+ int temp = getLargeNodeCount (root->children [i],x);
29+ count = count+temp;
30+ }
31+ if (root->data > x){
32+ count++;
33+ }
34+ return count;
35+ }
You can’t perform that action at this time.
0 commit comments