- DFS, Mathematical, n-ary-tree, Recursion, Tree

Kth largest element in an N-array Tree

  #include using namespace std;  class Node {public:    int data;    vector childs;};  int largestELe = INT_MIN;  void largestEleUnderRange(    Node* root, int data){            if (root->data < data) {        largestELe = max(root->data,                         largestELe);    }          for (Node* child : root->childs) {                  largestEleUnderRange(child, data);    }}  void KthLargestElement(Node* root,                       int K){            int ans = INT_MAX;          for (int i = 0; i < K; i++) {                                  largestEleUnderRange(root, ans);                          ans = largestELe;        largestELe = INT_MIN;    }          cout data = data;          return temp;}  int main(){                                        Node* root = newNode(10);    (root->childs).push_back(newNode(2));    (root->childs).push_back(newNode(34));    (root->childs).push_back(newNode(56));    (root->childs).push_back(newNode(100));    (root->childs[0]->childs).push_back(newNode(77));    (root->childs[0]->childs).push_back(newNode(88));    (root->childs[2]->childs).push_back(newNode(1));    (root->childs[3]->childs).push_back(newNode(7));    (root->childs[3]->childs).push_back(newNode(8));    (root->childs[3]->childs).push_back(newNode(9));      int K = 3;    KthLargestElement(root, K);      return 0;}