Question: Use the stack in following code to implement the converting of a given postfix expression into infix expression. / * * Linked stack implementation *

Use the stack in following code to implement the converting of a given postfix expression into infix
expression.
/** Linked stack implementation */
class IStack implements Stack {
private Link top;
// Pointer to first element
private int size:
//Number of elements
/** Constructors */
public LStack(){ top = null; size =0;}
public LStack (int size)
{top = null; size =0;}
/** Reinitialize stack */
public void clear(){top = null; size =0;}
/** Put "it" on stack */
public void push (E it){
top = new Link (it, top);
size++;}
/** Remove "it" from stack*/
public E pop(){
assert top != null: "Stack is empty";
E it = top.element ();
top =top.next ();
size--;
return it;}
/** @return Top value */
public E topvalue (){
assert top != null:"Stack is empty";
return top.element();}
/** @return Stack length */
public int length(){
return size;}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!