{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/binaryTree","result":{"data":{"blog":{"frontmatter":{"title":"BINARY TREE","thumbnail":"blog39","date":"January 12, 2021","dsaCppCodeFile":null},"excerpt":"<div class=\"my-2 p-2\">\n              <p>\n                In this blog post will study what is a binary tree, types,\n                properties and applications.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A tree with atmost two child nodes is called as a binary tree\n                  i.e. a binary tree can have either zero or one or two child\n                  nodes only.\n                </p>\n                <p>\n                  We can visualize a binary tree as consisting of a root and two\n                  disjoint binary trees.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Types</h4>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Strict BT: </strong>\n                  A binary tree is called strict binary tree if each node has\n                  exactly two children or no children.\n                </li>\n                <li>\n                  <strong>Perfect BT: </strong>\n                  A binary tree is called perfect/full binary tree if each node\n                  has exactly two children and all leaf nodes are at the same\n                  level.\n                </li>\n                <li>\n                  <strong>Complete BT: </strong>\n                  A binary tree is called complete binary tree if all leaf nodes\n                  are at height h or h – 1 and also without any missing number\n                  in the sequence (will see this in Heap Tree).\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Properties</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  The maximum no. of nodes in a BT of height h is\n                  2<sup>h+1</sup>+1.\n                </li>\n                <li>\n                  The number of leaf nodes in a perfect binary tree is\n                  2<sup>h</sup>.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>Binary Expression trees are used in compilers.</li>\n                <li>\n                  Binary Search Tree (BST), which supports search, insertion and\n                  deletion on a collection of items in O(logn) (average).\n                </li>\n                <li>\n                  Huffman coding trees that are used in data compression\n                  algorithms.\n                </li>\n                <li>\n                  Priority Queue (PQ), which supports search and deletion of\n                  minimum (or maximum) on a collection of items in logarithmic\n                  time (in worst case).\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/tree\">Tree Data Structure</a> |\n              <a href=\"/blogs/binarySearchTree\">Binary Search Trees</a> |\n              <a href=\"/blogs/binaryHeap\">Binary Heap</a>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <p>\n                In this blog post will study what is a binary tree, types,\n                properties and applications.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A tree with atmost two child nodes is called as a binary tree\n                  i.e. a binary tree can have either zero or one or two child\n                  nodes only.\n                </p>\n                <p>\n                  We can visualize a binary tree as consisting of a root and two\n                  disjoint binary trees.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Types</h4>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Strict BT: </strong>\n                  A binary tree is called strict binary tree if each node has\n                  exactly two children or no children.\n                </li>\n                <li>\n                  <strong>Perfect BT: </strong>\n                  A binary tree is called perfect/full binary tree if each node\n                  has exactly two children and all leaf nodes are at the same\n                  level.\n                </li>\n                <li>\n                  <strong>Complete BT: </strong>\n                  A binary tree is called complete binary tree if all leaf nodes\n                  are at height h or h – 1 and also without any missing number\n                  in the sequence (will see this in Heap Tree).\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Properties</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  The maximum no. of nodes in a BT of height h is\n                  2<sup>h+1</sup>+1.\n                </li>\n                <li>\n                  The number of leaf nodes in a perfect binary tree is\n                  2<sup>h</sup>.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>Binary Expression trees are used in compilers.</li>\n                <li>\n                  Binary Search Tree (BST), which supports search, insertion and\n                  deletion on a collection of items in O(logn) (average).\n                </li>\n                <li>\n                  Huffman coding trees that are used in data compression\n                  algorithms.\n                </li>\n                <li>\n                  Priority Queue (PQ), which supports search and deletion of\n                  minimum (or maximum) on a collection of items in logarithmic\n                  time (in worst case).\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/tree\">Tree Data Structure</a> |\n              <a href=\"/blogs/binarySearchTree\">Binary Search Trees</a> |\n              <a href=\"/blogs/binaryHeap\">Binary Heap</a>\n            </div>"},"thumbnail":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='225'%20viewBox='0%200%20400%20225'%20preserveAspectRatio='none'%3e%3cpath%20d='M38%2092l-1%2010v8h11v-9l2%204c1%204%202%205%204%205s3-1%203-10v-9h-2c-3%200-3%200-3%203v4l-1-4-4-3c-2%200-3%201-3%203-1%203-1%203-1%200%200-4%200-4-2-4s-3%201-3%202m27-1c-2%202-7%2014-7%2017%200%201%201%202%203%202l2-1%201-2%202-1c2%200%202%200%202%202%200%201%201%202%203%202s3-1%201-11c-2-8-4-10-7-8m14%200h-4v6c-2%2011-1%2013%201%2013s3-1%203-3c0-4%201-4%203%200%201%203%202%204%204%201v-4c-1-1-1-3%201-5%203-5%200-9-8-8m38%200l-5%201-1%202c0%202%200%202%202%202%203%200%203%200%203%207s0%207%202%207c3-1%203%200%203-9%200-5%200-6%202-6l2-2c0-2-1-3-2-3l-6%201m14%200c-4%200-4%200-4%205-2%2010-1%2014%201%2014s3-1%203-3l1-3%202%203c2%203%202%204%204%201v-3c-1-2-1-3%201-6%202-6%200-9-8-8m15%200l-4%201-1%209v9h4c7%200%209-1%209-3s-1-2-4-2c-5%200-5-2-1-3%204%200%204-4%200-4s-4-2%201-3c3%200%204-1%204-3s0-2-8-1m15%200c-6%200-6%201-6%2011v8h4c6%200%209-1%209-3s-1-2-4-2c-5%200-5-2-1-3%204%200%204-4%200-4s-4-2%201-2c3-1%204-2%204-4l-2-2-5%201M24%2094l-1%2010-1%206h5c7%200%2010-2%209-7v-6c2-4%200-6-6-6s-6%200-6%203m65-2l2%207%202%208c0%204%205%204%205%200l2-9c4-8%204-7%201-7-2%200-3%201-4%203l-1%204-2-4c-1-3-5-4-5-2m179%2010c-3%203-5%2013-3%2017%201%202%204%203%205%201%201-1-1-9-3-10-4-1%202-9%208-9%207%200%209%205%206%2011-2%205-2%208%200%209%204%201%207-8%204-9l-1-4c0-8-10-12-16-6m31%204l-1%208v7h17l-5%205a66%2066%200%2000-19%2037l-2%2010v1l6-7c7-9%2017-15%2017-10%200%202%201%203%203%203l2-2-1-3h3c3%200%202%201%200%204l-2%204v3h-17v7c0%206%200%207-2%208-3%202-3%203%200%203%202%200%203%204%201%206l-6%201c-9%200-11-4-7-9l2-5c0-3-8%206-8%2010-1%203-1%203-10%204-8%200-8%200-8%202s1%203%205%203c5%200%206%200%204%205-1%202%201%202%2048%202h49l1-4c1-2%202-3%205-3%205-1%205-4%200-5h-3v-14c0-14-1-21-4-21l-2-2-1-2c-7-1-7-4-3-12%207-13%207-17%200-22-4-3-5-4-5-8l-1-4c-1-1-1%201-1%204%200%205%200%205-2%204-3-1-19%200-23%201l-3%201v-10l-14-1-13%201m2%208v6h22v-13h-22v7m-31%2027l1%209h12v-18h-13v9m55%2016c0%201-1%202-3%202s-2%201-2%204v3h6c9%200%209%200%208%207l1%208v2l-1%203c0%204%200%204%205%204%207%201%208%200%208-5l-1-6-2-4-2-5-1-3h-1v-2l-3-5c-1-2-3-3-7-4l-5-2v3m-52%207l-1%205c0%203%200%204-1%203%200-4-2-3-3%200l2%204%202%203%203%201c2%200%202%200%202-3%200-2%200-3%202-3s2-1%202-4l-1-4-1%203c0%204-2%203-2-2-1-3-1-4-4-3'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.7699115044247788,"src":"/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/ee604/blog39.png","srcSet":"/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/69585/blog39.png 200w,\n/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/497c6/blog39.png 400w,\n/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/ee604/blog39.png 800w,\n/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/f3583/blog39.png 1200w,\n/static/4ba2720a29b6ed4e5846ad7b9d3b1d76/e4d72/blog39.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"binaryTree","thumbnail":"thumbnails/blog39.png"}},"staticQueryHashes":["2987289216","63159454"]}