0% found this document useful (0 votes)
10 views3 pages

ADSL-2 (1) Post To in

A2

Uploaded by

virenlahane7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

ADSL-2 (1) Post To in

A2

Uploaded by

virenlahane7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

using namespace std;

#include <cctype>

class node

public:

char data;

node *left, *right;

node (char x)

data=x;

left=right=NULL;

};

class stack

public:

int top;

node *st[50];

stack()

top=-1;

void push (node *temp)

st[++top]=temp;

node *pop()

return st[top--];

}
};

node *create()

char postfix[20];

int i=0;

stack s;

node *root;

cout<<"Enter postfix expression ";

cin>>postfix;

while(postfix [i]!='\0')

root=new node (postfix[i]);

if (isalnum(postfix[i]))

s.push(root);

else

root->right=s.pop();

root->left = s.pop();

s.push(root);

i++;

root= s.pop();

return root;

void in (node *temp)

if (temp!=NULL)

{
in(temp->left);

cout<<"\t"<<temp->data;

in (temp->right);

int main()

node *temp=create();

in (temp);

You might also like