{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/infixToPostfix","result":{"data":{"blog":{"frontmatter":{"title":"INFIX TO POSTFIX CONVERSION","thumbnail":"blog30","date":"December 25, 2020","dsaCppCodeFile":"https://drive.google.com/file/d/1OKuzeRCD07PLatgSY2eHKthW1rzt38VW/view?usp=sharing"},"excerpt":"<div class=\"my-2 p-2\">\n              <p>\n                Lets see the precedence of the operators that will be used to\n                convert the given infix to postfix expression and understand the\n                logic for conversion.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Precedence</h4>\n              <div class=\"table-responsive\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Precedence\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <tr>\n                      <th>Operator</th>\n                      <th>Stack precedence</th>\n                      <th>Input precedence</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <th>+ -</th>\n                      <th>2</th>\n                      <th>1</th>\n                    </tr>\n                    <tr>\n                      <th>/ *</th>\n                      <th>4</th>\n                      <th>3</th>\n                    </tr>\n                    <tr>\n                      <th>^</th>\n                      <th>6</th>\n                      <th>7</th>\n                    </tr>\n                    <tr>\n                      <th>(</th>\n                      <th>0</th>\n                      <th>9</th>\n                    </tr>\n                    <tr>\n                      <th>)</th>\n                      <th>-</th>\n                      <th>0</th>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for conversion</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                  Create an operator stack using arrays of type character.\n                </li>\n                <li>Scan the infix expression from left to right.</li>\n                <li>\n                  If the character read is an operand then add it to the postfix\n                  expression.\n                </li>\n                <li>\n                  Else loop until the stack is not empty and stack precedence of\n                  top is more than the input precedence.\n                  <ol class=\"pl-4\">\n                    <li>\n                      If the input character is ')' then pop the top of the\n                      stack and add it to the postfix expression until the top\n                      of stack is not '('.\n                    </li>\n                    <li>\n                      Once again pop the top of stack because it will obviously\n                      be '(' and break the loop(step 4).\n                    </li>\n                    <li>\n                      Else if the input character is not ')' then pop the top of\n                      stack and add to it the postfix expression.\n                    </li>\n                  </ol>\n                </li>\n                <li>\n                  If the step 4 condition fails and input character is not ')'\n                  then push the operator into the stack.\n                </li>\n                <li>\n                  After scanning all the characters of the infix expression, pop\n                  the top of operand stack and add it to the postfix expression\n                  untill the stack is not empty.\n                </li>\n                <li>Return the postfix expression.</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/infixToPrefix\">Infix to Prefix</a>\n              |\n              <a href=\"/blogs/evaluationOfPostfix&Prefix\"\n                >Evaluation of Postfix & Prefix Expressions</a\n              >\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <p>\n                Lets see the precedence of the operators that will be used to\n                convert the given infix to postfix expression and understand the\n                logic for conversion.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Precedence</h4>\n              <div class=\"table-responsive\">\n                <table class=\"table table-striped\">\n                  <caption class=\"text-center\">\n                    Precedence\n                  </caption>\n                  <thead class=\"thead-dark\">\n                    <tr>\n                      <th>Operator</th>\n                      <th>Stack precedence</th>\n                      <th>Input precedence</th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    <tr>\n                      <th>+ -</th>\n                      <th>2</th>\n                      <th>1</th>\n                    </tr>\n                    <tr>\n                      <th>/ *</th>\n                      <th>4</th>\n                      <th>3</th>\n                    </tr>\n                    <tr>\n                      <th>^</th>\n                      <th>6</th>\n                      <th>7</th>\n                    </tr>\n                    <tr>\n                      <th>(</th>\n                      <th>0</th>\n                      <th>9</th>\n                    </tr>\n                    <tr>\n                      <th>)</th>\n                      <th>-</th>\n                      <th>0</th>\n                    </tr>\n                  </tbody>\n                </table>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Logic for conversion</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                  Create an operator stack using arrays of type character.\n                </li>\n                <li>Scan the infix expression from left to right.</li>\n                <li>\n                  If the character read is an operand then add it to the postfix\n                  expression.\n                </li>\n                <li>\n                  Else loop until the stack is not empty and stack precedence of\n                  top is more than the input precedence.\n                  <ol class=\"pl-4\">\n                    <li>\n                      If the input character is ')' then pop the top of the\n                      stack and add it to the postfix expression until the top\n                      of stack is not '('.\n                    </li>\n                    <li>\n                      Once again pop the top of stack because it will obviously\n                      be '(' and break the loop(step 4).\n                    </li>\n                    <li>\n                      Else if the input character is not ')' then pop the top of\n                      stack and add to it the postfix expression.\n                    </li>\n                  </ol>\n                </li>\n                <li>\n                  If the step 4 condition fails and input character is not ')'\n                  then push the operator into the stack.\n                </li>\n                <li>\n                  After scanning all the characters of the infix expression, pop\n                  the top of operand stack and add it to the postfix expression\n                  untill the stack is not empty.\n                </li>\n                <li>Return the postfix expression.</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/infixToPrefix\">Infix to Prefix</a>\n              |\n              <a href=\"/blogs/evaluationOfPostfix&Prefix\"\n                >Evaluation of 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='M24%2090l-1%2012-1%208h11v-9l2%204c2%204%203%205%205%205s2%200%202-9%200-10-2-10c-1%200-2%201-2%203l-1%204-1-3c-3-7-7-6-7%201l-1%206v-6c0-5%200-6-2-6h-2m25%201c-5%200-6%201-6%2013%200%206%200%206%203%206%202%200%202%200%202-3s0-3%203-4c2%200%203-1%203-2%200-2-1-2-3-2-5%200-4-3%201-3l4-3c0-2%200-3-7-2m9-1l-2%2012v8h5c6%200%206%200%207-3l1-2%202%202c0%202%202%203%203%203%202%200%202%200%200-6-1-4-1-4%201-8%202-3%202-3%201-5-2-1-2-1-4%201-2%203-2%203-3%201s-3-3-5-1c-1%201%200%202%201%205l2%203-2%204-3%204v-9c0-9%200-9-2-9h-2m33%201c-5%200-5%200-5%203l2%202c2%200%202%201%202%207%200%207%200%207%203%207%202%200%202%200%202-7%200-8%200-8%203-8%202%200%202%200%202-2-1-3-2-3-9-2m12%202c-5%206-3%2018%204%2017%208-1%209-20%200-20l-4%203m38-2c-4%201-5%2013-2%2017%202%203%207%203%2010-2%204-8-1-18-8-15m28%200c-4%200-5%201-5%202h-1c-1-2-7-3-9%200-3%202-2%207%201%209s3%204%200%203c-4%200-5%202-2%204%204%203%2010%200%2010-5l-3-5-3-4%202%201c1%202%202%202%203%201%205-3%206-2%206%206%200%207%200%207%203%207%202%200%202%200%202-7s0-8%202-8%203-1%203-2c0-3-2-3-9-2m15%200c-5%200-6%201-6%2013%200%206%200%206%203%206%202%200%202%200%202-3s0-3%203-4c2%200%203-1%203-2%200-2-1-2-3-2-5%200-4-3%201-3l4-3c0-2%200-3-7-2m9-1l-2%2012v8h5c6%200%206%200%207-3l1-2%202%202c0%202%202%203%203%203%202%200%202%200%200-6-1-4-1-4%201-8%202-3%202-3%201-5-2-1-2-1-4%201-2%203-2%203-3%201s-3-3-5-1c-1%201%200%202%201%205l2%203-2%204-3%204v-9c0-9%200-9-2-9h-2m-69%202l-2%209v9h2c3%200%203%200%203-3%200-2%201-3%203-4%204-1%207-5%205-9%200-2-1-3-5-3l-6%201m144%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/2cc02a20dd5df992017a59036fa88b23/ee604/blog30.png","srcSet":"/static/2cc02a20dd5df992017a59036fa88b23/69585/blog30.png 200w,\n/static/2cc02a20dd5df992017a59036fa88b23/497c6/blog30.png 400w,\n/static/2cc02a20dd5df992017a59036fa88b23/ee604/blog30.png 800w,\n/static/2cc02a20dd5df992017a59036fa88b23/f3583/blog30.png 1200w,\n/static/2cc02a20dd5df992017a59036fa88b23/e4d72/blog30.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"infixToPostfix","thumbnail":"thumbnails/blog30.png"}},"staticQueryHashes":["2987289216","63159454"]}