From 8bc9f20d006a9cead30e7060b761e2759ac8b7ba Mon Sep 17 00:00:00 2001
From: nehatiwariii <76935552+nehatiwariii@users.noreply.github.com>
Date: Thu, 14 Oct 2021 23:30:09 +0530
Subject: [PATCH 1/2] Create print input tree level wise

---
 print input tree level wise | 82 +++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 print input tree level wise

diff --git a/print input tree level wise b/print input tree level wise
new file mode 100644
index 00000000..63dedefc
--- /dev/null
+++ b/print input tree level wise	
@@ -0,0 +1,82 @@
+#include <iostream>
+#include <vector>
+#include <queue>
+using namespace std;
+
+template <typename T>
+class TreeNode {
+   public:
+    T data;
+    vector<TreeNode<T>*> children;
+
+    TreeNode(T data) { this->data = data; }
+
+    ~TreeNode() {
+        for (int i = 0; i < children.size(); i++) {
+            delete children[i];
+        }
+    }
+};
+
+
+TreeNode<int>* takeInputLevelWise() {
+    int rootData;
+    cin >> rootData;
+    TreeNode<int>* root = new TreeNode<int>(rootData);
+
+    queue<TreeNode<int>*> pendingNodes;
+
+    pendingNodes.push(root);
+    while (pendingNodes.size() != 0) {
+        TreeNode<int>* front = pendingNodes.front();
+        pendingNodes.pop();
+        int numChild;
+        cin >> numChild;
+        for (int i = 0; i < numChild; i++) {
+            int childData;
+            cin >> childData;
+            TreeNode<int>* child = new TreeNode<int>(childData);
+            front->children.push_back(child);
+            pendingNodes.push(child);
+        }
+    }
+
+    return root;
+}
+#include<queue>
+void printLevelWise(TreeNode<int>* root) {
+    queue<TreeNode<int>*>pendingnodes;
+    pendingnodes.push(root);
+    while(pendingnodes.size()!=0)
+    {
+        TreeNode<int>*Front=pendingnodes.front();
+        pendingnodes.pop();
+        cout<<Front->data<<":";
+        if(Front->children.size()==0)
+            cout<<endl;
+        else
+        {
+        for(int i=0;i<Front->children.size();i++)
+        {   
+            if(i==Front->children.size()-1)
+                cout<<Front->children[i]->data<<endl;
+            else
+            {
+            cout<<Front->children[i]->data<<",";
+            }
+            TreeNode<int>* child= Front->children[i];
+            pendingnodes.push(child);
+            
+        }
+        }
+        
+    }
+    
+    
+}
+
+
+int main() {
+    TreeNode<int>* root = takeInputLevelWise();
+    printLevelWise(root);
+}

From 385275f873355e92f4902ccfe1509b94ebe60108 Mon Sep 17 00:00:00 2001
From: nehatiwariii <76935552+nehatiwariii@users.noreply.github.com>
Date: Thu, 14 Oct 2021 23:56:20 +0530
Subject: [PATCH 2/2] Create node with max childsum

---
 node with max childsum | 80 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 node with max childsum

diff --git a/node with max childsum b/node with max childsum
new file mode 100644
index 00000000..19725293
--- /dev/null
+++ b/node with max childsum	
@@ -0,0 +1,80 @@
+#include <iostream>
+#include <queue>
+#include <vector>
+using namespace std;
+
+template <typename T>
+class TreeNode {
+   public:
+    T data;
+    vector<TreeNode<T>*> children;
+
+    TreeNode(T data) { this->data = data; }
+
+    ~TreeNode() {
+        for (int i = 0; i < children.size(); i++) {
+            delete children[i];
+        }
+    }
+};
+
+
+TreeNode<int>* takeInputLevelWise() {
+    int rootData;
+    cin >> rootData;
+    TreeNode<int>* root = new TreeNode<int>(rootData);
+
+    queue<TreeNode<int>*> pendingNodes;
+
+    pendingNodes.push(root);
+    while (pendingNodes.size() != 0) {
+        TreeNode<int>* front = pendingNodes.front();
+        pendingNodes.pop();
+        int numChild;
+        cin >> numChild;
+        for (int i = 0; i < numChild; i++) {
+            int childData;
+            cin >> childData;
+            TreeNode<int>* child = new TreeNode<int>(childData);
+            front->children.push_back(child);
+            pendingNodes.push(child);
+        }
+    }
+
+    return root;
+}
+TreeNode<int>* maxSumNode(TreeNode<int>* root) 
+{
+    if(root==NULL)
+        return NULL;
+    int sum=root->data;
+    for(int i=0;i<root->children.size();i++)
+    {
+       sum=sum+root->children[i]->data; 
+    }
+    TreeNode<int>*ans=root;
+      for(int i=0;i<root->children.size();i++)
+      {
+        TreeNode<int>*max=maxSumNode(root->children[i]);
+          int q=max->data;
+
+        for(int i=0;i<max->children.size();i++){
+            q+=max->children[i]->data;  
+        }
+        if(q>sum){
+            sum=q;
+            ans=max;
+        }
+    }return ans;
+}
+   
+
+int main() {
+    TreeNode<int>* root = takeInputLevelWise();
+
+    TreeNode<int>* ans = maxSumNode(root);
+
+    if (ans != NULL) {
+        cout << ans->data;
+    }
+}