Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(python pls)Write a program that will treat an equation like a stack. It will po

ID: 3600013 • Letter: #

Question

(python pls)Write a program that will treat an equation like a stack. It will pop each character off of the stack to evaluate whether it is an operation, variable, constant or parenthesis. You will need to initialize each variable (with values prior to parsing the string which makes up the equation. For example it should be able to process (sin(sin(sin(sin(x))))) as wel as 5X(T/3)-X.

Explanation / Answer

Stack stack = new Stack(); while (n > 0) { stack.push(n % 2); n /= 2; } while (!stack.isEmpty()) StdOut.print(stack.pop()); StdOut.println(); Stack stack = new Stack(); while (!queue.isEmpty()) stack.push(queue.dequeue()); while (!stack.isEmpty()) queue.enqueue(stack.pop());