June 30, 2022 |2.6K Views

    Check if all levels of two trees are anagrams or not

      Share   Like
    Description
    Discussion

    Write a recursive program for level order traversal of a tree.


    Traverse each level of both the trees one by one and store the result of traversals in 2 different vectors, one for each tree.


    Sort both the vectors and compare them iteratively for each level, if they are same for each level then return true else return false.


    Time Complexity: O(n^2), where n is the number of nodes.


    Check if all levels of two trees are anagrams or not   : https://www.geeksforgeeks.org/check-if-all-levels-of-two-trees-are-anagrams-or-not/