{"id":84214,"date":"2021-09-20T09:00:23","date_gmt":"2021-09-20T03:30:23","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=84214"},"modified":"2021-09-20T09:00:23","modified_gmt":"2021-09-20T03:30:23","slug":"tree-traversal-in-data-structure","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/","title":{"rendered":"Tree Traversal in Data Structure"},"content":{"rendered":"<p>Tree traversal means visiting each node of the tree. The tree is a non-linear data structure, and therefore its traversal is different from other linear data structures. There is only one way to visit each node\/element in linear data structures, i.e. starting from the first value and traversing in a linear order. However, in tree data structures, there are multiple ways to traverse it.<\/p>\n<h3>Types of Tree Traversal:<\/h3>\n<p>Broadly, tree traversal is classified into two categories: Level order or breadth-first traversal and depth-first traversal. The depth-first traversal further has 3 different categories that we are going to study in detail.<\/p>\n<h3>Level Order Traversal:<\/h3>\n<p>In a level order traversal, the nodes are covered in a level-wise manner from left to right. We can implement a level order traversal with the help of a queue data structure.<\/p>\n<p>For example, the following diagram depicts the order of traversing the nodes of the tree.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84886\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image01.jpg\" alt=\"Traversing nodes of a tree\" width=\"647\" height=\"396\" \/><\/a><\/p>\n<p>Here, the level order traversal will print the nodes in the following order: 10, 20, 30, 40, 50, 60, 70.<\/p>\n<h3>Depth First Traversal:<\/h3>\n<p>In depth-first traversal, we go in one direction up to the bottom first and then come back and go to the other direction. There are three types of depth-first traversals. These are:<\/p>\n<p>1. Preorder traversal<\/p>\n<p>2. Inorder traversal<\/p>\n<p>3. Postorder traversal<\/p>\n<p>A binary tree is a recursive data structure. Also, each binary tree has 3 parts: a root node, a left subtree and a right subtree. These left and right subtrees are also trees in themselves and thus, again further described recursively.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image02.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84887\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image02.jpg\" alt=\"subtree in data structure\" width=\"540\" height=\"440\" \/><\/a><\/p>\n<p>A tree comprises multiple nodes. The structure of one node is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">struct Node {\n    int key;\n    struct Node* left;\n    struct Node* right;\n}\n<\/pre>\n<p>Thus, each node has 3 parts: A data item or key, a pointer to the left child and a pointer to the right child.<\/p>\n<h3>Preorder Traversal:<\/h3>\n<p>In a preorder traversal, we process\/visit the root node first. Then we traverse the left subtree in a preorder manner. Finally, we visit the right subtree again in a preorder manner.<\/p>\n<p>For example, consider the following tree:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image03.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84888\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image03.jpg\" alt=\"Preorder Traversal in data structure\" width=\"647\" height=\"475\" \/><\/a><\/p>\n<p>Here, the root node is A. All the nodes on the left of A are a part of the left subtree whereas all the nodes on the right of A are a part of the right subtree. Thus, according to preorder traversal, we will first visit the root node, so A will print first and then move to the left subtree.<\/p>\n<p>B is the root node for the left subtree. So B will print next and we will visit the left and right nodes of B. In this manner, we will traverse the whole left subtree and then move to the right subtree. Thus, the order of visiting the nodes will be: A\u2192B\u2192C\u2192D\u2192E\u2192F\u2192G\u2192H\u2192I.<\/p>\n<h4>Algorithm for Preorder Traversal:<\/h4>\n<p>for all nodes of the tree:<br \/>\nStep 1: Visit the root node.<br \/>\nStep 2: Traverse left subtree recursively.<br \/>\nStep 3: Traverse right subtree recursively.<\/p>\n<h4>Pseudo-code for Preorder Traversal:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void Preorder(struct node* ptr)\n{\n    if(ptr != NULL)\n    {\n        printf(\"%d\", ptr-&gt;data);\n        Preorder(ptr-&gt;left);\n        Preorder(ptr-&gt;right);\n    }\n}\n<\/pre>\n<h4>Uses of Preorder Traversal:<\/h4>\n<ul>\n<li>If we want to create a copy of a tree, we make use of preorder traversal.<\/li>\n<li>Preorder traversal helps to give a prefix expression for the expression tree.<\/li>\n<\/ul>\n<h3>Inorder Traversal:<\/h3>\n<p>In an inorder traversal, we first visit the left subtree, then the root node and then the right subtree in an inorder manner.<\/p>\n<p>Consider the following tree:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84889\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image04.jpg\" alt=\"Inorder Traversal of tree\" width=\"524\" height=\"475\" \/><\/a><\/p>\n<p>In this case, as we visit the left subtree first, we get the node with the value 30 first, then 20 and then 40. After that, we will visit the root node and print it. Then comes the turn of the right subtree. We will traverse the right subtree in a similar manner. Thus, after performing the inorder traversal, the order of nodes will be 30\u219220\u219240\u219210\u219250\u219270\u219260\u219280.<\/p>\n<h4>Algorithm for Inorder Traversal:<\/h4>\n<p>for all nodes of the tree:<br \/>\nStep 1: Traverse left subtree recursively.<br \/>\nStep 2: Visit the root node.<br \/>\nStep 3: Traverse right subtree recursively.<\/p>\n<h4>Pseudo-code for Inorder Traversal:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void Inorder(struct node* ptr)\n{\n    if(ptr != NULL)\n    {\n        Inorder(ptr-&gt;left);\n        printf(\"%d\", ptr-&gt;data);\n        Inorder(ptr-&gt;right);\n    }\n}\n<\/pre>\n<h4>Uses of Inorder Traversal:<\/h4>\n<ul>\n<li>Used to print the nodes of a binary search tree in non-decreasing order.<\/li>\n<li>We can also use the inorder traversal to get the non-increasing order of a BST.<\/li>\n<\/ul>\n<h3>Postorder Traversal:<\/h3>\n<p>Postorder traversal is a kind of traversal in which we first traverse the left subtree in a postorder manner, then traverse the right subtree in a postorder manner and at the end visit the root node.<\/p>\n<p>For example, in the following tree:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-84890\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/08\/TechVidvan-Tree-Traversal-normal-image05.jpg\" alt=\"Postorder traversal in data structure\" width=\"448\" height=\"475\" \/><\/a><\/p>\n<p>The postorder traversal will be 7\u21925\u21924\u219220\u219260\u219230\u219210.<\/p>\n<h4>Algorithm for Postorder Traversal:<\/h4>\n<p>for all nodes of the tree:<\/p>\n<p>Step 1: Traverse left subtree recursively.<br \/>\nStep 2: Traverse right subtree recursively.<br \/>\nStep 3: Visit the root node.<\/p>\n<h4>Pseudo-code for Postorder Traversal:<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">void Postorder(struct node* ptr)\n{\n    if(ptr != NULL)\n    {\n        Postorder(ptr-&gt;left);\n        Postorder(ptr-&gt;right);\n        printf(\u201c%d\u201d, ptr-&gt;data);\n    }\n}\n<\/pre>\n<h4>Uses of Postorder Traversal:<\/h4>\n<ul>\n<li>It helps to delete the tree.<\/li>\n<li>It helps to get the postfix expression in an expression tree.<\/li>\n<\/ul>\n<h3>Implementation of Traversal in C:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n\nstruct Node {\n    int key;\n    struct Node* left;\n    struct node* right;\n};\n\nvoid inorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    inorder_traversal(root-&gt;left);\n    printf(\"%d -&gt;\", root-&gt;key);\n    inorder_traversal(root-&gt;right);\n}\n\nvoid preorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    printf(\"%d -&gt;\", root-&gt;key);\n    preorder_traversal(root-&gt;left);\n    preorder_traversal(root-&gt;right);\n}\n\nvoid postorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    postorder_traversal(root-&gt;left);\n    postorder_traversal(root-&gt;right);\n    printf(\"%d -&gt;\", root-&gt;key);\n}\n\nstruct Node* create_node(value) {\n    struct Node* new_node = malloc(sizeof(struct Node));\n    new_node-&gt;key = value;\n    new_node-&gt;left = NULL;\n    new_node-&gt;right = NULL;\n    return new_node;\n}\n\nstruct Node* insert_left(struct Node* root, int value) {\n    root-&gt;left = create_node(value);\n    return root-&gt;left;\n}\n\nstruct Node* insert_right(struct Node* root, int value) {\n    root-&gt;right = create_node(value);\n    return root-&gt;right;\n}\n\nint main() {\n    struct node* root = create_node(1);\n    insert_left(root, 12);\n    insert_right(root, 9);\n\n    insert_left(root-&gt;left, 5);\n    insert_right(root-&gt;left, 6);\n\n    printf(\"Inorder traversal \\n\");\n    inorder_traversal(root);\n\n    printf(\"\\nPreorder traversal \\n\");\n    preorder_traversal(root);\n\n    printf(\"\\nPostorder traversal \\n\");\n    postorder_traversal(root);\n}\n<\/pre>\n<h3>Traversal Implementation in C++:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;bits\/stdc++.h&gt;\n\nstruct Node {\n    int key;\n    struct Node* left;\n    struct node* right;\n};\n\nvoid inorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    inorder_traversal(root-&gt;left);\n    cout &lt;&lt; \"-&gt;\" &lt;&lt; root-&gt;key;\n    inorder_traversal(root-&gt;right);\n}\n\nvoid preorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    cout &lt;&lt; \"-&gt;\" &lt;&lt; root-&gt;key;\n    preorder_traversal(root-&gt;left);\n    preorder_traversal(root-&gt;right);\n}\n\nvoid postorder_traversal(struct node* root) {\n    if (root == NULL) \n        return;\n    postorder_traversal(root-&gt;left);\n    postorder_traversal(root-&gt;right);\n    cout &lt;&lt; \"-&gt;\" &lt;&lt; root-&gt;key;\n}\n\nstruct Node* create_node(value) {\n    struct Node* new_node = malloc(sizeof(struct Node));\n    new_node-&gt;key = value;\n    new_node-&gt;left = NULL;\n    new_node-&gt;right = NULL;\n    return new_node;\n}\n\nstruct Node* insert_left(struct Node* root, int value) {\n    root-&gt;left = create_node(value);\n    return root-&gt;left;\n}\n\nstruct Node* insert_right(struct Node* root, int value) {\n    root-&gt;right = create_node(value);\n    return root-&gt;right;\n}\n\nint main() {\n    struct node* root = create_node(1);\n    insert_left(root, 12);\n    insert_right(root, 9);\n\n    insert_left(root-&gt;left, 5);\n    insert_right(root-&gt;left, 6);\n\n    cout &lt;&lt; \"Inorder traversal \\n\";\n    inorder_traversal(root);\n\n    cout &lt;&lt; \"\\nPreorder traversal \\n\";\n    preorder_traversal(root);\n\n    cout &lt;&lt; \"\\nPostorder traversal \\n\";\n    postorder_traversal(root);\n}\n<\/pre>\n<h3>Implementation of traversal in Java:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Node {\n    int data;\n    Node left, right;\n\n    public Node(int key) {\n    data = key;\n    left = right = null;\n    }\n}\n\nclass Binary_tree {\n    Node root;\n\n    Binary_tree() {\n    root = null;\n  }\n\n    void postorder_traversal(Node node) {\n        if (node == null)\n            return;\n        postorder_traversal(node.left);\n        postorder_traversal(node.right);\n        System.out.print(node.data + \"-&gt;\");\n    }\n    \n    void inorder_traversal(Node node) {\n        if (node == null)\n            return;\n        inorder_traversal(node.left);\n        System.out.print(node.data + \"-&gt;\");\n        inorder_traversal(node.right);\n    }\n\n    void preorder_traversal(Node node) {\n        if (node == null)\n            return;\n        System.out.print(node.data + \"-&gt;\");\n        preorder_traversal(node.left);\n        preorder_traversal(node.right);\n    }\n\n    public static void main(String[] args) {\n        Binary_tree tree = new Binary_tree();\n        tree.root = new Node(10);\n        tree.root.left = new Node(12);\n        tree.root.right = new Node(30);\n        tree.root.left.left = new Node(15);\n        tree.root.left.right = new Node(25);\n\n        System.out.println(\"Inorder traversal\");\n        tree.inorder(tree.root);\n\n        System.out.println(\"\\nPreorder traversal \");\n        tree.preorder(tree.root);\n\n        System.out.println(\"\\nPostorder traversal\");\n        tree.postorder(tree.root);\n    }\n}\n<\/pre>\n<h3>Implementation of traversal in Python:<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class Node:\n    def __init__(self, data):\n        self.left = None\n        self.right = None\n        self.val = data\n\n\ndef inorder_traversal(root):\n    if root:\n        inorder_traversal(root.left)\n        print(str(root.val) + \"-&gt;\", end='')\n        inorder_traversal(root.right)\n\ndef postorder_traversal(root):\n    if root:\n        postorder_traversal(root.left)\n        postorder_traversal(root.right)\n        print(str(root.val) + \"-&gt;\", end='')\n\n\ndef preorder_traversal(root):\n    if root:\n        print(str(root.val) + \"-&gt;\", end='')\n        preorder_traversal(root.left)\n        preorder_traversal(root.right)\n\n\nroot = Node(10)\nroot.left = Node(12)\nroot.right = Node(30)\nroot.left.left = Node(15)\nroot.left.right = Node(25)\n\nprint(\"Inorder traversal \")\ninorder(root)\n\nprint(\"\\nPreorder traversal \")\npreorder(root)\n\nprint(\"\\nPostorder traversal \")\npostorder(root)\n<\/pre>\n<h3>Applications of Binary Tree:<\/h3>\n<ul>\n<li>The most important application of the binary tree is that it is used to implement the heap data structure.<\/li>\n<li>Used in compiler design to create syntax trees that help to ensure the correctness of the syntax.<\/li>\n<li>Binary trees help in accessing data easily.<\/li>\n<li>Used in computer networks to implement routing algorithms in routers.<\/li>\n<\/ul>\n<h3>Conclusion:<\/h3>\n<p>This article covers different types of traversal possible for the tree data structure. We have seen the different possible ways to visit all the nodes of a tree. Traversal is a very important operation as it is the basis of other operations. We have seen the implementation of tree traversal in different programming languages such a C, C++, Java and Python.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tree traversal means visiting each node of the tree. The tree is a non-linear data structure, and therefore its traversal is different from other linear data structures. There is only one way to visit&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":84882,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3555],"tags":[4271,4272,4273,4274],"class_list":["post-84214","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-structure","tag-applications-of-binary-tree","tag-implementation-of-tree-traversal","tag-tree-traversal","tag-types-of-tree-traversal"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Tree Traversal in Data Structure - TechVidvan<\/title>\n<meta name=\"description\" content=\"Learn what is traversal of tree in data structure. See its levels and types with examples and implementation. See applications of binary tree\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tree Traversal in Data Structure - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Learn what is traversal of tree in data structure. See its levels and types with examples and implementation. See applications of binary tree\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-20T03:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tree Traversal in Data Structure - TechVidvan","description":"Learn what is traversal of tree in data structure. See its levels and types with examples and implementation. See applications of binary tree","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Tree Traversal in Data Structure - TechVidvan","og_description":"Learn what is traversal of tree in data structure. See its levels and types with examples and implementation. See applications of binary tree","og_url":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-09-20T03:30:23+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Tree Traversal in Data Structure","datePublished":"2021-09-20T03:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/"},"wordCount":895,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg","keywords":["Applications of Binary Tree","Implementation of Tree Traversal","Tree Traversal","Types of Tree Traversal"],"articleSection":["Data Structure Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/","url":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/","name":"Tree Traversal in Data Structure - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg","datePublished":"2021-09-20T03:30:23+00:00","description":"Learn what is traversal of tree in data structure. See its levels and types with examples and implementation. See applications of binary tree","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/08\/TechVidvan-Tree-Traversal.jpg","width":1200,"height":628,"caption":"Tree Traversal in data structure"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/tree-traversal-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Tree Traversal in Data Structure"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=84214"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/84214\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/84882"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=84214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=84214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=84214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}