Answered step by step
Verified Expert Solution
Question
1 Approved Answer
queue.h #ifndef QUEUE_H #define QUEUE_H #include common.h typedef struct queue { NODE *front; NODE *rear; } QUEUE; void enqueue (QUEUE *qp, NODE *np); NODE *dequeue
queue.h #ifndef QUEUE_H #define QUEUE_H #include common.h" typedef struct queue { NODE *front; NODE *rear; } QUEUE; void enqueue (QUEUE *qp, NODE *np); NODE *dequeue (QUEUE *qp); void clean_queue (QUEUE *qp); #endif stack.h #ifndef STACK_H #define STACK H #include "common.h" typedef struct stack { NODE *top; } STACK; void push(STACK *sp, NODE *np); NODE *pop (STACK *sp); void clean_stack (STACK *sp); #endif Question 3 Postfix and infix expression evaluation Write C programs expression.h, expression.c to evaluate arithmetic infix expression. Use the queue data structure of Q1 to represent postfix expression. Use the stack data structure of Q2 to represent the stack for postfix expression evaluation. * convert infix expression in string to postfix expression represented by QUEUE and return the postfix expression queue. QUEUE infix_to_postfix(char *infixstr); /* * evaluate and returns the value postfix expression passed by queue. int evaluate_postfix (QUEUE queue); /* * evaluate and return the value of prefix expression passed by string infixstr, using infix_to_postfix() and evaluate_postfix() functions. int evaluate_prefix(char *infixstr); Use provided main program expression main.c to test above functions. Public test gcc common.c queue.c stack.c expression.c expression_main.c -o q3 q3 infix expression:10-((3* 4)+8)/4 postfix expression:10 3 4 * 8 + 4 / - postfix evaluation: 5 prefix evaluation: 5 q3 "12 + 24+3" infix expression:12 + 24*3 postfix expression:12 24 3 * + postfix evaluation: 84 prefix evaluation: 84 Amylearningspace.wlu.ca Order Completa CP264 A6 Assignment.pdf (68) PRIME ICON PLAYER PIC.. Chicopee Tube Park Fikayo Tomori FIFA 21 - 76 - R... Assignments - CP-264-8 - Dat... Help for question 3 Postfix and infix evaluation expression.h #include "common.h" #include "queue.h" * convert infix expression in string to postfix expression represented by QUEUE and retur. QUEUE infix_to_postfix(char *infixstr); * evaluate and returns the value postfix expression passed by queue. int evaluate_postfix QUEUE queue); /* * evaluate and return the value of prefix expression passed by string infixstr, using in int evaluate_prefix(char *infixstr); expression.c Hinclude #include #include "common.h" #include "queue.h" #include "stack.h" #include "expression.h" * auxiliary function int get_priority(char op) { if (op == '/' || op == || op =- '*') return 1; else if (op == '+' = || op == '-') return 0 else return -1; > expression.c #include #include #include "common.h" #include "queue.h" #include "stack.h" #include "expression.h" 1 op == * auxiliary function */ int get_priority(char op) { if (op == '/' || op == '') return 1; else if (op== '+' || op == '-') return 0; else return -1; } * auxiliary function int type(char c) { if (c >= '0' && c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started