Answer to Question #202012 in Python for reeeeg

Question #202012

Can you please rewrite this program without using class and def, The question is given below. i didn't input all the code because it's too long. i need a simple one.


Create a program that will convert an infix expression entered by the user to its equivalent prefix and postfix expression Sample Output: Enter an Infix Expression: a+b^(c^d- e/(f+g)+(h^i)^j) <input> Postfix Expression: abcd^efg+/- hi^j^+^+ <compute> Prefix Expression: +a^b+- ^cd/e+fg^^hij


class infix_to_prefix:

  precedence={'^':5,'*':4,'/':4,'+':3,'-':3,'(':2,')':1}

  def __init__(self):

    self.items=[]

    self.size=-1

  def push(self,value):

    self.items.append(value)

    self.size+=1

  def pop(self):

    if self.isempty():

      return 0

    else:


1
Expert's answer
2021-06-03T04:12:38-0400
#infix_to_prefix
precedence={'^':5,'*':4,'/':4,'+':3,'-':3,'(':2,')':1}
items=[]
size=-1


items.append(value)
size+=1


ret=1


if isempty():
    ret=0


else:

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS