Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

QUESTION

(a) Convert each of the following expressions to prefix and postfix.

(i) (A+B)*(C+D)

(ii) A-B/(C*D^E) (^ denotes exponentiation)

(b) The following algorithm converts an infix expression into its postfix representation. We have assumed that the infix expressions contain only the operators +, -, * and /. The expressions do not contain parentheses. Examples of valid expressions are A+B*C and A/B+C/D-E.

opstk = the empty stack;

while (not end of input) {

symb = next input character;

if (symb is an operand)

add symb to the postfix string

else{

while(!empty(opstk) && prcd(stacktop(opstk),symb)){

topsymb = pop(opstk);

add topsymb to the postfix string;

}

push(opstk,symb);

}

}

while(!empty(opstk)){

topsymb = pop(opstk);

add topsymb to the postfix string;

}

(i) Write the function empty in C. The function empty must return TRUE if the stack is empty and FALSE if the stack is not empty.

(ii) Write the function pop in C. The function must perform the following three actions:

1. If the stack is empty, print a warning message and halt execution.

2. Remove the top element from the stack.

3. Return the top element of the stack to the calling function.

(iii) Write the function prcd(op1,op2) in C, where op1 and op2 are characters representing operators. The function prcd(op1,op2) must return TRUE if op1 has precedence over op2 when op1 appears to the left of op2 in an infix expression. The function prcd(op1,op2) returns FALSE otherwise.

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9586298

Have any Question?


Related Questions in Computer Engineering

Why would a policy of re-importation of prescription drugs

Why would a policy of re-importation of prescription drugs be ineffective?

In 2005 team dad used a toyota truck with a system of

In 2005, Team DAD used a Toyota truck with a system of spinning lasers as its "visual" system. What advantages and or disadvantage does such a system have compared to camera-based systems?

Ambrose has indifference curves with the equation x2 k -

Ambrose has indifference curves with the equation x2 = k - 4(x^0.5) ... Where the larger "k" is, the higher the indifference curve. If good 1 is drawn on the horizontal axis, and good 2 on the vertical... What is the SLO ...

Solve the question given belowwhat is the relative market

Solve the question given below What is the relative market share for the top three cell phone service providers in the united states? The response must be typed, single spaced, must be in times new roman font (size 12) a ...

What decimal number does the bit pattern 0xc0d40000

What decimal number does the bit pattern 0xC0D40000 represent if it is: A two's complement integer An unsigned integer A floating point number assuming the IEE 754 single precision format Please provide a detailed explan ...

Subnetting ip adress - 190 3500750 subnetwhat is the

Subnetting : IP adress - 190. 35.0.0 750 subnet What is the subnet mask? How many bit? What is 2 n-2 host? What is 2 n subnets? What are the first 5 subnets? What is the first and last IP of 2nd block? Answer all the que ...

Answer as thorough as possiblenbspinclude an explanation of

Answer as thorough as possible, Include an explanation of your recommendations or trading strategies. Should you early exercise the following American-style put option? If not always, under what situation would you early ...

Recommend a mechanism that will record event data on the

Recommend a mechanism that will record event data on the folders for each department. What events should be logged and how often do these logs need to be reviewed? Recommend an implementation for antivirus software. Sugg ...

Write a python 3 program please show all outputlambda and

Write a Python 3 Program please show all output. lambda and keyword Magic Goals A bit of lambda functions as objects keyword evaluation Task Write a function that returns a list of n functions, such that each one, when c ...

Question bullusing the spss software open the high school

Question: • Using the SPSS software, open the High School Longitudinal Study dataset (ATTACHED). • Based on the dataset you chose, construct a research question that can be answered with a Pearson correlation and bivaria ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As