{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/evaluationOfPostfix&Prefix","result":{"data":{"blog":{"frontmatter":{"title":"EVALUATION OF POSTFIX & PREFIX EXPRESSIONS","thumbnail":"blog32","date":"December 28, 2020","dsaCppCodeFile":"https://drive.google.com/file/d/1upbkYH9B3ZkQcA_8gdIvRursz9eYmJEB/view?usp=sharing"},"excerpt":"<div class=\"my-2 p-2\">\n              <p>\n                Lets see the logic to evaluate both postfix & prefix\n                expressions.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for evaluating Postfix</h4>\n              <p class=\"text-muted\">\n                Do refer the code available the end of this section to\n                understand the following thoery.\n              </p>\n              <ol class=\"pl-4\">\n                <li>Create stack for operands using arrays of float type.</li>\n                <li>Scan the postfix expression from left to right.</li>\n                <li>\n                  If the character read is an operand then convert it into it's\n                  corresponding numeric value and push it to the stack.\n                </li>\n                <li>\n                  Else perform the following operation:\n                  <ol class=\"pl-4\">\n                    <li>Pop the top of stack and save it as operand2.</li>\n                    <li>\n                      Once again pop the top of stack and save it as operand1.\n                    </li>\n                    <li>\n                      Compute the relevant operation between operand1,\n                      operator(character read) & operand2.\n                    </li>\n                    <li>Push this result to the stack.</li>\n                  </ol>\n                </li>\n                <li>\n                  After scanning all the characters of the postfix expression,\n                  pop the top of stack and save is as result.\n                </li>\n                <li>\n                  If the stack is not empty then the given postfix expression is\n                  invalid. Else print the result.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for evaluating Prefix</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>Create stack for operands using arrays of float type.</li>\n                <li>Scan the prefix expression from right to left.</li>\n                <li>\n                  If the character read is an operand then convert it into it's\n                  corresponding numeric value and push it to the stack.\n                </li>\n                <li>\n                  Else perform the following operation:\n                  <ol class=\"pl-4\">\n                    <li>Pop the top of stack and save it as operand1.</li>\n                    <li>\n                      Once again pop the top of stack and save it as operand2.\n                    </li>\n                    <li>\n                      Compute the relevant operation between operand1,\n                      operator(character read) & operand2.\n                    </li>\n                    <li>Push this result to the stack.</li>\n                  </ol>\n                </li>\n                <li>\n                  After scanning all the characters of the prefix expression,\n                  pop the top of stack and save is as result.\n                </li>\n                <li>\n                  If the stack is not empty then the given prefix expression is\n                  invalid. Else print the result.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/stack\">Stack</a>\n              |\n              <a href=\"/blogs/infixPrefixPostfixExpressions\"\n                >Infix VS Postfix VS Prefix</a\n              >\n              |\n              <a href=\"/blogs/infixToPostfix\">Infix to Postfix</a>\n              |\n              <a href=\"/blogs/infixToPrefix\">Infix to Prefix</a>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <p>\n                Lets see the logic to evaluate both postfix & prefix\n                expressions.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for evaluating Postfix</h4>\n              <p class=\"text-muted\">\n                Do refer the code available the end of this section to\n                understand the following thoery.\n              </p>\n              <ol class=\"pl-4\">\n                <li>Create stack for operands using arrays of float type.</li>\n                <li>Scan the postfix expression from left to right.</li>\n                <li>\n                  If the character read is an operand then convert it into it's\n                  corresponding numeric value and push it to the stack.\n                </li>\n                <li>\n                  Else perform the following operation:\n                  <ol class=\"pl-4\">\n                    <li>Pop the top of stack and save it as operand2.</li>\n                    <li>\n                      Once again pop the top of stack and save it as operand1.\n                    </li>\n                    <li>\n                      Compute the relevant operation between operand1,\n                      operator(character read) & operand2.\n                    </li>\n                    <li>Push this result to the stack.</li>\n                  </ol>\n                </li>\n                <li>\n                  After scanning all the characters of the postfix expression,\n                  pop the top of stack and save is as result.\n                </li>\n                <li>\n                  If the stack is not empty then the given postfix expression is\n                  invalid. Else print the result.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for evaluating Prefix</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>Create stack for operands using arrays of float type.</li>\n                <li>Scan the prefix expression from right to left.</li>\n                <li>\n                  If the character read is an operand then convert it into it's\n                  corresponding numeric value and push it to the stack.\n                </li>\n                <li>\n                  Else perform the following operation:\n                  <ol class=\"pl-4\">\n                    <li>Pop the top of stack and save it as operand1.</li>\n                    <li>\n                      Once again pop the top of stack and save it as operand2.\n                    </li>\n                    <li>\n                      Compute the relevant operation between operand1,\n                      operator(character read) & operand2.\n                    </li>\n                    <li>Push this result to the stack.</li>\n                  </ol>\n                </li>\n                <li>\n                  After scanning all the characters of the prefix expression,\n                  pop the top of stack and save is as result.\n                </li>\n                <li>\n                  If the stack is not empty then the given prefix expression is\n                  invalid. Else print the result.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/stack\">Stack</a>\n              |\n              <a href=\"/blogs/infixPrefixPostfixExpressions\"\n                >Infix VS Postfix VS Prefix</a\n              >\n              |\n              <a href=\"/blogs/infixToPostfix\">Infix to Postfix</a>\n              |\n              <a href=\"/blogs/infixToPrefix\">Infix to Prefix</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='M28%2091c-5%200-5%200-5%203l-1%2010v6h4c6%200%209-1%209-3s-1-2-3-2l-4-1c-1-1%201-2%204-2l2-2c0-2-1-2-3-2-4%200-4-2%201-3l4-2%202%208c2%209%202%209%205%209%203-1%209-17%206-19-2-1-4%201-5%206v4l-2-5c-2-6-3-6-14-5m30%201c-2%202-7%2016-6%2017%201%202%205%201%205%200%200-3%204-3%205-1%200%202%205%203%205%201%200-4-2-15-4-17-1-2-2-3-5%200m11%201l-1%2010v7h6l6-1c0-2%200-2%202%200h8c2-1%204-7%204-13%200-5%200-5-2-5-3%200-3%200-3%205%200%206-1%209-3%209l-1-7c1-7%201-7-2-7-2%200-3%203-3%2010%200%203%200%203-4%203h-3v-7c0-6%200-7-2-7-1%200-2%201-2%203m33-2c-2%200-5%208-8%2017%200%203%204%203%206%200l3-2%201%202%203%202c3%200%203%201%201-10-1-8-3-10-6-9m14%200c-5%200-5%200-5%203l2%202c2%200%202%201%202%207%200%207%200%207%203%207%202%200%202%200%202-7s0-8%202-8l2-2c1-2%200-3-2-3l-6%201m10%201l-1%2010v8h2c3%200%203%200%203-3v-3l2%203c4%207%2012%202%2012-8%200-9-8-12-12-4-1%201-1%201-1-2s0-3-2-3-3%201-3%202m45%200c-3%202-4%2010-3%2014%205%209%2014%202%2013-9-1-7-5-9-10-5m17-1l-5%201-1%208c-1%2010-1%2010%202%2010%202%200%202-1%202-3%200-3%200-3%204-4%204%200%205-4%200-4-4%200-4-3%200-4%204%200%206-3%204-4h-6m-42%202l-1%2010c0%207%200%207%203%207%202%200%202%200%202-4v-4l2%204c4%209%207%203%207-12%200-3%200-3-2-3-3%200-3%200-3%203v4l-1-4c-2-4-6-4-7-1m122%209c-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%205a67%2067%200%2000-19%2036l-2%2010c0%203-1%203%208-7%205-8%2015-12%2015-8%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-22v7M25%20124c-2%200-2%200-2%2016-1%204%203%204%204%200%200-2%201-3%203-3%205-2%208-9%204-12-2-2-4-2-9-1m14%202c-3%205-3%2012%200%2014%205%205%2011%200%2011-8%200-9-7-12-11-6m15-1c-3%203-3%206%201%209%203%203%203%206%200%204-2-1-3-1-3%201-1%202%201%203%205%203%207%200%208-6%203-10-3-2-4-5-2-5l1%202c0%201%203%201%207-1%202%200%202%201%202%207%200%207%200%207%203%207%202%200%202%200%202-7%200-6%200-7%203-7l2-3c0-3-14-3-14%200%200%202%200%202-1%201-1-4-6-4-9-1m26-1l-2%2017c1%203%205%201%205-2s0-3%203-3c5-1%205-4%200-5-4%200-3-2%201-3%203%200%204-1%204-3s0-2-5-2l-6%201m13%200v1l-1%209-1%208h6c5%200%206%200%207-2l1-2%201%202%203%202h3l-2-5-2-5%202-3c2-3%203-5%200-5-1-1-2%200-3%201l-1%202-2-2c-2-2-2-2-4-1-1%202-1%202%201%205%201%204%201%204-1%208l-3%205v-19h-3c-1%200-2%200-1%201m32%201l-2%205c1%201%200%202-1%203-1%202-1%205%201%207%201%202%2012%202%2013%200l-1-2v-3c2-3%202-3%200-3-1-1-2-2-1-3%201-5-5-8-9-4m24-1c-2%201-2%201-2%209l-1%208-1%201c2%202%205%200%205-3%200-1%201-2%203-2%204-2%206-4%206-8%200-5-3-7-10-5m13%200l-2%209v9h2c2%200%203-1%203-3l1-3%202%203c2%203%203%204%205%202%201-1%200-2-1-4v-4c2-3%202-6%200-8-1-2-8-3-10-1m14%201l-1%2010v7h7c6%200%206%200%206-2%200-3%200-3-4-3l-4-1%202-1c3%200%205-1%204-3%200-1-1-2-3-2l-3-1%204-1%204-1%201-2c0-2-1-2-6-2-6%200-7%200-7%202m14-1l-1%2010v8h2c3%200%203%200%203-3s0-3%203-3%203%200%203-2c0-3%200-3-3-3-5%200-4-3%201-3%203%200%204-1%204-3s0-2-5-2l-7%201m13%204v14h5l6-2%202-2%201%202c0%201%201%202%203%202s2%200%200-7c-1-2-1-3%201-6s3-5%200-5c-1-1-2%200-3%201l-3%202c-1-4-2-4-4-3l-2%201%202%203%202%204-2%204-3%205v-9c0-9%200-9-2-9s-3%200-3%205m67%2013l1%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/b2071dd8c831554857045cb037cd7a3a/ee604/blog32.png","srcSet":"/static/b2071dd8c831554857045cb037cd7a3a/69585/blog32.png 200w,\n/static/b2071dd8c831554857045cb037cd7a3a/497c6/blog32.png 400w,\n/static/b2071dd8c831554857045cb037cd7a3a/ee604/blog32.png 800w,\n/static/b2071dd8c831554857045cb037cd7a3a/f3583/blog32.png 1200w,\n/static/b2071dd8c831554857045cb037cd7a3a/e4d72/blog32.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"evaluationOfPostfix&Prefix","thumbnail":"thumbnails/blog32.png"}},"staticQueryHashes":["2987289216","63159454"]}