June 02, 2022 |3.1K Views

    Mirror of n-ary Tree

      Share   Like
    Description
    Discussion

    Node of tree is represented as a key and a variable sized array of children pointers. The idea is similar to mirror of Binary Tree. For every node, we first recur for all of its children and then reverse array of children pointers. We can also do these steps in other way, i.e., reverse array of children pointers first and then recur for children.
    Below is C++ implementation of above idea.

    Mirror of n-ary Tree: https://www.geeksforgeeks.org/mirror-of-n-ary-tree/