answersLogoWhite

0

What else can I help you with?

Continue Learning about Engineering

Algorithm for converting prefix to postfix using stack?

/*Infix to Prefix And Postfix*/ /*Assignment:5*/ /*Roll No:2102*/ #include<stdio.h> #include<conio.h> #include<string.h> #define MAX 15 #define true 1 #define false 0 /*Structure Decvlaration*/ typedef struct { char data[MAX]; char top; }STK; /*Function Declarations*/ void input(char str[]); void intopre(char str1[],char pre[]); void intopost(char str1[],char post[]); int isoperand(char sym); int prcd(char sym); void push(STK *s1,char elem); int pop(STK *s1); int empty(STK *s2); int full(STK *s2); void dis(char str[]); void main() { STK s; int cs,ans; char str[MAX],pre[MAX],post[MAX]; clrscr(); do /*Using Do-while Loop*/ { clrscr(); printf(" -----Program for Expressions-----"); printf(" Input The String:"); printf(" MENU: "); printf("1.Infix to Prefix "); printf("2.Infix to Postfix"); printf(" 3.Exit"); cs=getche(); switch(cs) /*Using Switch Case*/ { case 1: intopre(str,pre); break; case 2: intopost(str,post); break; case 3: break; default: printf(" Enter a Valid Choise!"); /*Default Case*/ break; } printf(" Do you wish to Continue?(y/n)"); ans=getche(); }while(ans=='y'ans=='Y'); /*Condition for Do-while loop*/ getch(); } /**************************************************/ /*To Input String*/ /**************************************************/ void input(char str) { printf("Enter the Infix String:"); scanf("%s",str); } /**************************************************/ /*To Covert Infix To Prefix*/ /**************************************************/ void intopre(STK s1,char str1[],char pre[]) { int len,flag; len=strlen(str1); int check=0,cnt=len-1,pos=0; char elem; while(cnt>=0) /*while condition*/ { flag=0; if(isoperand(str1[cnt])) /*Checking for Operand*/ { printf("%c",str1[cnt]); cnt--; pos++; } else { check=prcd(str1[cnt]); while(check==false) { pre[pos]=str1[cnt]; flag=1; pos++; cnt--; } if(flag==0) { elem=pop(&s1); printf("%c",elem); } } } } /**************************************************/ /*To Convert Infix To Postfix*/ /**************************************************/ void intopost(STK s1,char str1[],char post[]) { int len; len=strlen(str1); int check=0,cnt=len-1,pos=0; } /**************************************************/ /*To Check For Operand*/ /**************************************************/ int isoperand(char sym) { if('A'<sym<'Z''a'<sym<'z') return(true); return(false); } /**************************************************/ /*To Check The Precedence*/ /**************************************************/ int prcd(char sym) { } /**************************************************/ /*To Display String*/ /**************************************************/ void dis(char str[]) { } /******************************************/ /*Push Function Definition*/ /******************************************/ void push(STK *s1,char elem) { if(!full(s1)) { s1->top++; /*Incrementing top*/ s1->data[s1->top]=elem; /*Storing element*/ } else printf(" Stack is Full!"); } /******************************************/ /*Full Function Definition*/ /******************************************/ int full(STK *s2) { if(s2->top==MAX) /*Condition for Full*/ return(true); return(false); } /******************************************/ /*Pop Function Definition*/ /******************************************/ int pop(STK *s1) { char elem; if(!empty(s1)) { elem=s1->data[s1->top]; /*Storing top stack element in elem*/ s1->top--; /*Decrementing top*/ return(elem); } return(false); } /******************************************/ /*Empty Function Definition*/ /******************************************/ int empty(STK *s2) { if(s2->top==-1) /*Condition For Empty*/ return(true); return(false); }


What is a strainer post?

A strainer post is a fence post.


What are the types of tool post?

the types of tool post on lathes can be classified as single screw tool post four bolt tool post open side tool post four way tool post


What is the accuracy of the investment casting process for steel?

There are two main controlling factors in this process When an investment casting sets it generally shrinks upto a few millimetres from its cast size. Depending on the complexity of the component being made more advanced machinery or more skilled die makers may be required to produce the required shape. In a premium casting upto 1/8 of a millimetre is attainable- to achieve this however there will high set up costs due to the following items. When designing the die to accomodate for post-cast shrinkage the number and complexity of calculations and simulations will be large. The cost and machining time for the die cutting, and the cost of the materials involved will be much higher. The die will require a long post-process, both before production commences and between batches to maintain die consistency and quality. For a commercial standard casting this tolerance will be around +/- 0.5mm depending on the complexity of shape. On the lowest budget this can grow to as high as +/- 2mm. All the above applies for castings <0.5kg.


What is joint command post?

A joint command post is a post from which different groups are directed. It usually is a post manned by the leaders of different sections of the armed forces, or by leaders of armed forces of different countries.

Related Questions

Which data structure is needed to convert infix notations to post fix notations?

stack is the basic data structure needed to convert infix notation to postfix


How many meters have you got to be from the rugby post to kick a conversion?

5


How does one post a job listing?

Job postings are done by registering for the service/website. Once register, you can post a job for a posted fee. Fees vary by the degree of complexity of the advertisement.


Am I physically capable of using a post pounder?

Depending on the complexity of Post Pounder you purchase or rent, you may be able to do this project yourself. Here is a Post Pounder that is more sophisticated that may be good for a professional to do: http://www.wikco.com/fencepost.html


How can one do conversion from yen to dollar?

Most financial institutions post conversion rates for major currencies including the conversion from yen to dollar. Currency calculators are also available online at sites such as Xrates and Coinmill.


How do you convert teaters to oz and grams?

explain to them of the general excellence of oz and grams and share your own post-conversion experience with them


Why is it impossible to port an algorithm written in C plus plus in a data general machine to an IBM computer?

It is not impossible. If the original algorithm was written in a portable fashion it should be portable. If not, then it won't be. Its as simple as that. One of the factors of portability with an IBM MainFrame is the endian-ness of the integers. The MainFrame is big-endian, while most other computers are little-endian. This, however, should not be a problem unless the original algorithm was incorrectly written, i.e. being dependent on internal bit representation. You don't specify the algorithm. It would be helpful if you could post it here, and we can analyze it...


How much can you get for your 1992 Chevy conversion van in good condition with 89332 miles?

I will post a link. The value depends on where you live and how the van is equipped.


This is the post conversion name of Saul of Tarsus who served as a tireless missionary in spreading Christianity's message?

Paul was the new name of Saul of Tarsus.


Where can one find the post office exchange rates?

Post Office exchange rates can be found online on the post office website. Using their system, the user can enter the value for which they want conversion into a different currency. They can also check exchange rate comparison websites to see if the Post Office provides the more cost effective deal.


Where can one find a converter to convert British pounds to USD?

When seeking the conversion rate of British pounds to USD the common reference is your local bank. If unable to access your local bank personally, currency conversion is also available at the local post office.


Algorithm for converting prefix to postfix using stack?

/*Infix to Prefix And Postfix*/ /*Assignment:5*/ /*Roll No:2102*/ #include<stdio.h> #include<conio.h> #include<string.h> #define MAX 15 #define true 1 #define false 0 /*Structure Decvlaration*/ typedef struct { char data[MAX]; char top; }STK; /*Function Declarations*/ void input(char str[]); void intopre(char str1[],char pre[]); void intopost(char str1[],char post[]); int isoperand(char sym); int prcd(char sym); void push(STK *s1,char elem); int pop(STK *s1); int empty(STK *s2); int full(STK *s2); void dis(char str[]); void main() { STK s; int cs,ans; char str[MAX],pre[MAX],post[MAX]; clrscr(); do /*Using Do-while Loop*/ { clrscr(); printf(" -----Program for Expressions-----"); printf(" Input The String:"); printf(" MENU: "); printf("1.Infix to Prefix "); printf("2.Infix to Postfix"); printf(" 3.Exit"); cs=getche(); switch(cs) /*Using Switch Case*/ { case 1: intopre(str,pre); break; case 2: intopost(str,post); break; case 3: break; default: printf(" Enter a Valid Choise!"); /*Default Case*/ break; } printf(" Do you wish to Continue?(y/n)"); ans=getche(); }while(ans=='y'ans=='Y'); /*Condition for Do-while loop*/ getch(); } /**************************************************/ /*To Input String*/ /**************************************************/ void input(char str) { printf("Enter the Infix String:"); scanf("%s",str); } /**************************************************/ /*To Covert Infix To Prefix*/ /**************************************************/ void intopre(STK s1,char str1[],char pre[]) { int len,flag; len=strlen(str1); int check=0,cnt=len-1,pos=0; char elem; while(cnt>=0) /*while condition*/ { flag=0; if(isoperand(str1[cnt])) /*Checking for Operand*/ { printf("%c",str1[cnt]); cnt--; pos++; } else { check=prcd(str1[cnt]); while(check==false) { pre[pos]=str1[cnt]; flag=1; pos++; cnt--; } if(flag==0) { elem=pop(&s1); printf("%c",elem); } } } } /**************************************************/ /*To Convert Infix To Postfix*/ /**************************************************/ void intopost(STK s1,char str1[],char post[]) { int len; len=strlen(str1); int check=0,cnt=len-1,pos=0; } /**************************************************/ /*To Check For Operand*/ /**************************************************/ int isoperand(char sym) { if('A'<sym<'Z''a'<sym<'z') return(true); return(false); } /**************************************************/ /*To Check The Precedence*/ /**************************************************/ int prcd(char sym) { } /**************************************************/ /*To Display String*/ /**************************************************/ void dis(char str[]) { } /******************************************/ /*Push Function Definition*/ /******************************************/ void push(STK *s1,char elem) { if(!full(s1)) { s1->top++; /*Incrementing top*/ s1->data[s1->top]=elem; /*Storing element*/ } else printf(" Stack is Full!"); } /******************************************/ /*Full Function Definition*/ /******************************************/ int full(STK *s2) { if(s2->top==MAX) /*Condition for Full*/ return(true); return(false); } /******************************************/ /*Pop Function Definition*/ /******************************************/ int pop(STK *s1) { char elem; if(!empty(s1)) { elem=s1->data[s1->top]; /*Storing top stack element in elem*/ s1->top--; /*Decrementing top*/ return(elem); } return(false); } /******************************************/ /*Empty Function Definition*/ /******************************************/ int empty(STK *s2) { if(s2->top==-1) /*Condition For Empty*/ return(true); return(false); }