Programing Assignment

Order Description

1. Practical part: (a) 15 POINTS - Write a clear () function that empties a stack recursively. The base case must be explicitly identified with a comment. Your function should only take a stack object as an argument. You can use pre-defined classes of Stacks. (b) 40 POINTS - Write a function postfixToInfix () which receives a String composed of operators and operands in postfix order and returns the expression'equivalente in infix order. The function must use a battery and it must be able to handle the following binary operators: +, -, ×, ÷, <,>, =

As well as the following unary operators: √,! The Strings that make up the postfix expressions that will test your implementation of postfixToInfix () will look like this: i. postfixToInfix ("15 7 1 1 + - / 3 * 2 1 1 + + -") must return "((15 / (7 - (1 + 1))) * 3) - (2 + (1 + 1))"

ii. postfixToInfix ("n! n 1 +! <") must return "n! <(n + 1)!"

iii. postfixToInfix ("9 √ 3 =") must return √9 = 3 "

It is important to take into account that each operator and operand is separated from a space in the String containing the postfix expression. An operand can contain more than one character, as in example i. In the String that returns the infix expression, everything must Also be separated by spaces except for parentheses and unary operators (the! Comes directly after n in ii and the √ just before 9 in iii). Do not add parentheses when an operand is simply a number or a letter. However, if an operator becomes a mathematical expression (such as n + 1 in ii), you must add parentheses to the left and right of the operand. The square root symbol can be obtained with the unicode character '\ u221A'.

2. Suppose we have an empty pile. We are writing a program that calls a total of 10 times the pop () function, 4 times the peek () function and 20 times the push () function. Are we able to determine the size of this stack once our program is running? If yes, give the size of this stack and explain your calculation. If not, explain why we could not calculate it.

Answer it in a word document