{"id":6384,"date":"2025-11-19T11:35:19","date_gmt":"2025-11-19T06:05:19","guid":{"rendered":"https:\/\/study.madeeasy.in\/?p=6384"},"modified":"2025-11-19T13:04:45","modified_gmt":"2025-11-19T07:34:45","slug":"tree-abstract-data-type-made-easy","status":"publish","type":"post","link":"https:\/\/www.madeeasy.in\/study\/cs-it\/tree-abstract-data-type-made-easy","title":{"rendered":"Tree &#8211; Abstract Data Type | MADE EASY"},"content":{"rendered":"<p style=\"text-align: justify;\">A Tree is a data structure similar to linked lists but instead of each node pointing simply to the next node in a linear fashion, each node points to a number of nodes. Trees is an example of non-linear data structures.<\/p>\n<p style=\"text-align: justify;\">It is a hierarchical data structure which stores the information naturally in the form of hierarchy style. In trees ADT (Abstract Data Type), order of the elements is not important. If we need ordering information linear data structures like linked lists, stacks, queues, etc. can be used.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6387 size-full\" src=\"https:\/\/study.madeeasy.in\/wp-content\/uploads\/2025\/11\/tree.jpg\" alt=\"Trees\" width=\"347\" height=\"260\" srcset=\"https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/11\/tree.jpg 347w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/11\/tree-300x225.jpg 300w\" sizes=\"auto, (max-width: 347px) 100vw, 347px\" \/><\/p>\n<ul>\n<li style=\"text-align: justify;\">The root of a tree is the node with no parents. There can be at most one root node in a tree (node A in the above example).<\/li>\n<li style=\"text-align: justify;\">An edge refers to the link from parent to child (all links in the figure).<\/li>\n<li style=\"text-align: justify;\">A node with no children is called leaf node (E, J, K, H and I)<\/li>\n<li style=\"text-align: justify;\">Children of same parent are called siblings (B, C, D are siblings and children of A and E, F are the siblings and children of B).<\/li>\n<li style=\"text-align: justify;\">A node p is an ancestor of a node q if there exists a path from root to q and p appears on the path.<\/li>\n<li style=\"text-align: justify;\">The node q is called a descendant of p. For example, A, C and G are the ancestors for K.<\/li>\n<li style=\"text-align: justify;\">The depth of a node is the length of the path from the root to the node (depth of G is 2, A-C-G).<\/li>\n<li style=\"text-align: justify;\">The height of a node is the length of the path from the root to the node to the deepest node. The height of a tree is the length of a path from the root to the deepest node in the tree. A (rooted) tree with only one node (the root) has a height of zero. In the previous example, height of B is 2(B-F-J).\u00a0Height of the tree is the maximum height among all the nodes in the tree and depth of the tree is the maximum depth among all the nodes in the tree. For a given tree depth and height returns the same value. But for individual nodes we may get different results.<\/li>\n<li style=\"text-align: justify;\">Size of a node is the number of descendants it has including itself (size of the subtree C is 3).<\/li>\n<li style=\"text-align: justify;\">Set of all nodes at a given depth is called level of the tree (B, C and D are same level). The root node is at level zero.<\/li>\n<li style=\"text-align: justify;\">If every node in a tree has only one child (except leaf nodes) then we call such trees as skew trees. If every node has only left child then we call them as left skew trees. Similarly, if every node has only right child then we call them as right skew trees.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-6390 size-full\" src=\"https:\/\/study.madeeasy.in\/wp-content\/uploads\/2025\/11\/skew.jpg\" alt=\"Skew\" width=\"820\" height=\"217\" srcset=\"https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/11\/skew.jpg 820w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/11\/skew-300x79.jpg 300w, https:\/\/www.madeeasy.in\/study\/wp-content\/uploads\/2025\/11\/skew-768x203.jpg 768w\" sizes=\"auto, (max-width: 820px) 100vw, 820px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Tree is a data structure similar to linked lists but instead of each node pointing simply to the next<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,94],"tags":[1894,1893],"class_list":["post-6384","post","type-post","status-publish","format-standard","hentry","category-cs-it","category-operating-system","tag-abstract-data-type","tag-tree"],"_links":{"self":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/comments?post=6384"}],"version-history":[{"count":0,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6384\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/media?parent=6384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/categories?post=6384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/tags?post=6384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}