Write the function pop in c, Basic Computer Science

Assignment Help:

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.

 


Related Discussions:- Write the function pop in c

Constant bit rate atm theory, For the connections that request a static amo...

For the connections that request a static amount of bandwidth that is continuously available during the connection lifetime. Is intended to support real time applications requiring

Software Exploration, I need to review 2 different softwares one is windows...

I need to review 2 different softwares one is windows based and the other is Linux Based. Please Ask for further details

Data buses, Data buses: The availability of reliable digital semi-condu...

Data buses: The availability of reliable digital semi-conductor technology has enabled the inter-communication task between different equipment to be significantly improved. P

Wat do u do, can u write my assignment for me

can u write my assignment for me

Learn, The technique to mix C and assembly language is to apply the "asm" d...

The technique to mix C and assembly language is to apply the "asm" directive. To access C-language variables from assembly language, you just use the C identifier that name is a me

Data communications and networks, A magazine publisher based in Nairobi has...

A magazine publisher based in Nairobi has branch in Kisumu, and one in Mombasa. The company has kept in touch by telephone and courier service. Each office is networked. The networ

File sharing architecture, File Sharing Architecture:   The developmen...

File Sharing Architecture:   The development of microprocessor, PC and LAN transformed dumb terminals into -smart? clients. This brought a complete change in the computing env

Telecommunication networks architecture, Telecommunication Networks Archite...

Telecommunication Networks Architecture is the manner in which the components of thenetwork are organized and integrated to provide telecommunication services to users ofthe netwo

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd