{"id":566,"date":"2021-02-04T00:40:43","date_gmt":"2021-02-03T19:10:43","guid":{"rendered":"https:\/\/www.codingbroz.com\/?p=566"},"modified":"2022-07-01T21:10:59","modified_gmt":"2022-07-01T15:40:59","slug":"generic-n-ary-tree-traversal","status":"publish","type":"post","link":"https:\/\/www.codingbroz.com\/generic-n-ary-tree-traversal\/","title":{"rendered":"Generic N-ary Tree Traversal"},"content":{"rendered":"\n

Traversal in a tree is a process of visiting each node of a tree. We can not randomly access any node. As every node in a tree is connected through edges, we need to start from the root node to traverse the node. There are many ways to traverse a generic tree ( N-ary tree) but we will be discussing 2 of the commonly used traversals :<\/p>\n\n\n\n

  1. Pre-Order traversal<\/li>
  2. Post-Order traversal<\/li><\/ol>\n\n\n\n

    Generally, we traverse a tree to search or locate a given item or key in the tree or to print all the values it contains.<\/p>\n\n\n\n

    \"Generic<\/figure>\n\n\n\n
    \n