{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/stack","result":{"data":{"blog":{"frontmatter":{"title":"STACK DATA STRUCTURE","thumbnail":"blog26","date":"December 12, 2020","dsaCppCodeFile":"https://drive.google.com/file/d/1HbIsYmbgEkL5PN8mVVM1iotb--XK9IPy/view?usp=sharing"},"excerpt":"<div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A stack is an ordered list in which insertion and deletion are\n                  done at one end, called top. The last element inserted is the\n                  first one to be deleted. Hence, it is called the Last in First\n                  out (LIFO) or First in Last out (FILO) list. In a stack, the\n                  order in which the data arrives is important.\n                </p>\n                <p>\n                  A pile of plates in a cafeteria is a good example of a stack.\n                  The plates are added to the stack as they are cleaned and they\n                  are placed on the top. When a plate, is required it is taken\n                  from the top of the stack. The first plate placed on the stack\n                  is the last one to be used.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>Balancing of symbols/brackets in an expression.</li>\n                <li>\n                  Conversion & Evaluation of infix, postfix, prefix\n                  expression(to be discussed in seperate blog posts).\n                </li>\n                <li>Implementing function calls (including recursion).</li>\n                <li>\n                  Used in many algorithms like Tower of Hanoi, tree traversals,\n                  stock span problem, histogram problem.\n                </li>\n                <li>\n                  In Graph Algorithms like Topological Sorting and Strongly\n                  Connected Components\n                </li>\n                <li>Browser history.</li>\n                <li>Matching Tags in HTML.</li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Standard Operations</h4>\n              <p class=\"text-muted\">\n                Do refer the code available the end of this section to\n                understand the following theory.\n              </p>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Push:</strong> Insert an item at the top of the stack.\n                  If there is no place then stack is in overflow state.\n                </li>\n                <li>\n                  <strong>Pop:</strong> Remove the top item from the stack. If\n                  there are no elements then the stack is in underflow state.\n                </li>\n                <li>\n                  <strong>isEmpty:</strong> To check whether stack is empty or\n                  not.\n                </li>\n                <li>\n                  <strong>isFull:</strong> To check if stack is full or not.\n                </li>\n                <li><strong>Peek</strong> Access the top item of the stack.</li>\n                <li>\n                  <strong>Display</strong> Display the items in the stack.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/stackUsingLinkedLists\"\n                >Stack using Linked Lists</a\n              >\n              |\n              <a href=\"/blogs/infixPrefixPostfixExpressions\"\n                >Infix, Postfix, Prefix Expressions</a\n              >\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A stack is an ordered list in which insertion and deletion are\n                  done at one end, called top. The last element inserted is the\n                  first one to be deleted. Hence, it is called the Last in First\n                  out (LIFO) or First in Last out (FILO) list. In a stack, the\n                  order in which the data arrives is important.\n                </p>\n                <p>\n                  A pile of plates in a cafeteria is a good example of a stack.\n                  The plates are added to the stack as they are cleaned and they\n                  are placed on the top. When a plate, is required it is taken\n                  from the top of the stack. The first plate placed on the stack\n                  is the last one to be used.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>Balancing of symbols/brackets in an expression.</li>\n                <li>\n                  Conversion & Evaluation of infix, postfix, prefix\n                  expression(to be discussed in seperate blog posts).\n                </li>\n                <li>Implementing function calls (including recursion).</li>\n                <li>\n                  Used in many algorithms like Tower of Hanoi, tree traversals,\n                  stock span problem, histogram problem.\n                </li>\n                <li>\n                  In Graph Algorithms like Topological Sorting and Strongly\n                  Connected Components\n                </li>\n                <li>Browser history.</li>\n                <li>Matching Tags in HTML.</li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Standard Operations</h4>\n              <p class=\"text-muted\">\n                Do refer the code available the end of this section to\n                understand the following theory.\n              </p>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Push:</strong> Insert an item at the top of the stack.\n                  If there is no place then stack is in overflow state.\n                </li>\n                <li>\n                  <strong>Pop:</strong> Remove the top item from the stack. If\n                  there are no elements then the stack is in underflow state.\n                </li>\n                <li>\n                  <strong>isEmpty:</strong> To check whether stack is empty or\n                  not.\n                </li>\n                <li>\n                  <strong>isFull:</strong> To check if stack is full or not.\n                </li>\n                <li><strong>Peek</strong> Access the top item of the stack.</li>\n                <li>\n                  <strong>Display</strong> Display the items in the stack.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/stackUsingLinkedLists\"\n                >Stack using Linked Lists</a\n              >\n              |\n              <a href=\"/blogs/infixPrefixPostfixExpressions\"\n                >Infix, Postfix, Prefix Expressions</a\n              >\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='M41%2091l-6%201h-1c0-2-8-1-9%201-3%203-2%206%201%208%204%204%204%205%200%205-4-1-5%202-1%203%203%201%206%201%208-1%203-3%202-6-1-8l-3-4h1c1%202%204%202%205%201l3-1c2%200%202%200%202%207%200%206%200%207%202%207s3-4%203-12c0-2%200-3%202-3l2-2c0-2-1-3-2-3l-6%201m16%200l-4%209c-4%209-4%2010%200%2010l2-1%201-2%202-1c2%200%202%200%202%202%200%201%201%202%203%202s2-1%201-10c-1-7-4-10-7-9m13%202c-6%205-5%2017%202%2017%203%200%207-4%207-6s-2-2-4%200l-2%201c-2%200-1-7%200-10%202-1%202-1%202%201%200%203%200%203%203%203s3-5%200-7c-3-3-4-2-8%201m12-2l-1%2010c0%209%200%209%202%209s3-1%203-3l1-3%201%203c3%203%204%203%205%201%201-1%201-3-1-5l-2-3%203-4c2-3%202-3%201-5-2-1-2-1-5%201-2%204-3%204-3%201s-3-4-4-2m186%2011c-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%203s3-1%201-2l-1-3h4c3%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%204l-23%201-3%201v-10l-14-1-13%201m2%208v6h22v-13h-22v7M24%20124l-1%2010v9l3-1c5%200%207-2%208-5%202-4%202-9%200-12-1-2-7-3-10-1m18%202l-4%209-2%207h3l3-1c1-2%205-3%205-1s4%203%205%202l-3-17c-1-3-6-3-7%201m11%200c0%203%200%203%202%203%202-1%202-1%202%206s0%207%203%207c2%200%202%200%202-7%200-6%200-7%203-7l2-3c0-2-1-2-7-2h-7v3m20%200c-2%202-6%2015-6%2016h3l3-1c0-3%204-2%204%200%201%202%204%202%205%201s-2-16-3-18c-2-2-5-1-6%202m21%200c-3%203-3%205%202%209l4%203h-4c-3%200-3%200-3%202%200%203%208%203%2010%200s1-6-2-8l-3-4h1c1%202%205%203%205%201l3-1c2%200%202%200%202%207s0%207%202%207%203-1%203-2c0-11%200-12%202-12l2-3c0-2-1-2-6-2-6%200-7%200-7%202h-2c-3-3-7-2-9%201m27-2l-2%209v9h2c2%200%203-1%203-3l1-3%201%203c2%203%203%203%205%202v-3c-1-3-1-4%201-6v-6c-2-3-8-4-11-2m14%201v15c1%203%208%203%2010%200%203-4%203-17%200-17-2%200-3%203-3%2010%200%204-1%206-3%205v-8c0-6%200-7-2-7l-2%202m16%200c-3%204-4%2011-2%2014%203%204%208%204%2011%200%202-3%200-5-3-2s-5-1-3-7c1-3%204-4%203-1-1%202%200%202%202%202l3-1c0-1%201-2%203-2s2%200%202%207%200%207%203%207l2-1v-7c0-5%200-6%202-6l2-3c0-2-1-2-6-2-7%200-7%200-7%202v2l-2-2c-3-3-7-3-10%200m27%201v15l5%201c5%200%207-3%207-11%200-7%200-8-2-8-1%200-2%201-3%207-1%209-2%209-3%200%200-6%200-7-2-7-1%200-2%201-2%203m15-2l-2%209v9h2c2%200%203-1%203-3l1-3%201%203c2%203%203%203%205%202v-3c-1-2-1-4%201-6%201-3%201-5-1-7-1-2-8-3-10-1m14%201l-1%2010v7h7c6%200%206%200%206-2%200-3%200-3-4-3-5%200-5-2-1-2%204-1%204-5%200-5l-3-1%204-1c3%200%204%200%204-2%201-3%200-3-6-3-5%200-6%200-6%202m63%2016l1%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%2010-1%207-7v-5l-1-3-3-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/b51831cf7aadb3908046b03b446a82b6/ee604/blog26.png","srcSet":"/static/b51831cf7aadb3908046b03b446a82b6/69585/blog26.png 200w,\n/static/b51831cf7aadb3908046b03b446a82b6/497c6/blog26.png 400w,\n/static/b51831cf7aadb3908046b03b446a82b6/ee604/blog26.png 800w,\n/static/b51831cf7aadb3908046b03b446a82b6/f3583/blog26.png 1200w,\n/static/b51831cf7aadb3908046b03b446a82b6/e4d72/blog26.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"stack","thumbnail":"thumbnails/blog26.png"}},"staticQueryHashes":["2987289216","63159454"]}