{"id":277,"date":"2018-10-31T17:47:27","date_gmt":"2018-10-31T17:47:27","guid":{"rendered":"https:\/\/books.compclassnotes.com\/elementarycomputing\/?page_id=277"},"modified":"2018-11-05T12:23:43","modified_gmt":"2018-11-05T12:23:43","slug":"converting-from-prefix-to-infix-the-stack-method","status":"publish","type":"page","link":"https:\/\/books.compclassnotes.com\/elementarycomputing\/converting-from-prefix-to-infix-the-stack-method\/","title":{"rendered":"Converting From Prefix to Infix: The Stack Method"},"content":{"rendered":"<p>Here is the algorithm we will use for converting from infix to prefix:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; notranslate\" title=\"\">\r\n\r\n1. Reverse the expression\r\n\r\n2. Read expression one character at a time\r\n\r\n3. Depending on character read:\r\n        &quot;)&quot;: Push onto stack\r\n        Operator: Push onto stack\r\n        Operand: Push on and pop off (straight to output)\r\n        &quot;(&quot;: Keep popping until corresponding &quot;)&quot; is encountered\r\n\r\n4. Reverse the output\r\n\r\n<\/pre>\n<p>And that&#8217;s it!<\/p>\n<p>For now you can use the <a href=\"http:\/\/moodle2.csis.ul.ie\/pluginfile.php\/15304\/mod_resource\/content\/4\/Stacks001.rkt\">stack code from Moodle<\/a>\u00a0to practice, but we&#8217;ll shortly have an interactive version here too.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is the algorithm we will use for converting from infix to prefix: 1. Reverse the expression 2. Read expression one character at a time 3. Depending on character read: &quot;)&quot;: Push onto stack Operator: Push onto stack Operand: Push <span class=\"readmore\"><a href=\"https:\/\/books.compclassnotes.com\/elementarycomputing\/converting-from-prefix-to-infix-the-stack-method\/\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-277","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/pages\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":12,"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/pages\/277\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/pages\/277\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/books.compclassnotes.com\/elementarycomputing\/wp-json\/wp\/v2\/media?parent=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}