Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this programming assignment, you will expand the pseudo code discussed in class for an arithmetic calculator that uses two different stacks, then implement the

In this programming assignment, you will expand the pseudo code discussed in class for an arithmetic
calculator that uses two different stacks, then implement the Java solution of the algorithm. However,
we first need to start by creating the stacks, as you are NOT allowed to use any built-in types from the
language. Doing so, will void your assignment.
I) Implement your stack using expandable arrays. Since the length of the expression is
unknown ahead of time, your stack will expand as needed. You should however keep two
important points in mind while implementing your stacks:
a) Amortized time complexity for adding any element to the stacks cannot be more than
O(1); and
b) Space complexity can NOT be more than the exact number of items that you finally
pushed into the stack (i.e. exactly O(n) for n elements).
II) Now, as your stacks are ready, you can continue with the problem itself, where you need
to use your stacks to calculate the value of a given mathematical expression. The expression
will include particular set of binary operators (see below) as well as parentheses pairs
(possibly nested ones).
In particular, your arithmetic calculators must read lines of text from a text file, where each
line contains a syntactically correct arithmetic expression. Your output will be directed to
a file, where you will record the input line (the expression) and print the computed result
on the next line.
Your calculators must support the following operators on integers and observe the standard
operator precedence as shown below (1 to 6, where 1 is the highest and 6 is the lowest.
Same precedence operators are evaluated from left to right).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

How would you approach this unit?

Answered: 1 week ago

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago