Find Jobs
Hire Freelancers

Expression Evaluation using Stacks

$30-5000 USD

Completed
Posted over 21 years ago

$30-5000 USD

Paid on delivery
Expression Evaluation using Stacks First, get the file [login to view URL] that will serve as your input. This is a file with each line being an integer algebraic expression that you will evaluate. Print each expression and its value, one per line. Setup an ADT Stack type (based on a linked list) so you can have a stack of integers whenever you need one. The expressions consist of integer constants and operators +, -, *, /, ( and ). Multiplication and division are to have higher precedence than addition and subtraction. Generally, a stack is used in this process. There are 2 main steps in evaluating an expression. First, you need to translate the expression from infix to postfix. For example, a * (b + c) is an infix expression whose postfix equivalent is a b c + *. Computers like postfix expressions because they are VERY easy to evaluate (which is your second step). To evaluate a postfix expression, setup a stack of ints and scan the string from left to right. Push any data value onto the stack. When you see an operator, apply it to the top 2 stack values, pushing the result back onto the stack. At the end, the top of the stack will be the value of the whole expression. First, however you need to translate infix to postfix. A stack is used here as well. Here is the algorithm: Scan the infix string from left to right. When you see a digit, collect any more adjacent digits into one integer value and simply place that value directly into the postfix string you are building. Other non-blank characters are handled as follows: (Let c = the character in question): if c is + - * / or ) then while stack is not empty and precedence(c) <= precedence(TOS) pop the stack add the popped value to the end of the postfix string if not ( end while if c is not ) then push c onto stack else if stack is not empty, pop it end if if c is (, just push it. After you are done scanning the infix string, you need to pop remaining operators off the stack, as with while stack not empty pop the stack add the popped value to the end of the postfix string if not ( end while The 'precedence' function is just an int returning function that you write. It takes a char c input parameter and bascially returns 1 if C is + or -, 2 if c is * or / and 0 if c is anything else. ## Deliverables Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. Complete copyrights to all work purchased. ## Platform Please write this program in C++, I use the Visual C++ 6.0 to compile and run it. ## Deadline information please deliver the codes ontime
Project ID: 2868110

About the project

11 proposals
Remote project
Active 22 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$17 USD in 14 days
5.0 (51 reviews)
3.2
3.2
11 freelancers are bidding on average $70 USD for this job
User Avatar
See private message.
$10.20 USD in 14 days
4.8 (35 reviews)
4.9
4.9
User Avatar
See private message.
$42.50 USD in 14 days
4.7 (41 reviews)
4.7
4.7
User Avatar
See private message.
$10.20 USD in 14 days
4.1 (54 reviews)
4.8
4.8
User Avatar
See private message.
$8.50 USD in 14 days
4.8 (62 reviews)
4.2
4.2
User Avatar
See private message.
$20.40 USD in 14 days
5.0 (38 reviews)
4.1
4.1
User Avatar
See private message.
$15.30 USD in 14 days
5.0 (7 reviews)
2.6
2.6
User Avatar
See private message.
$85 USD in 14 days
5.0 (2 reviews)
0.7
0.7
User Avatar
See private message.
$289 USD in 14 days
5.0 (1 review)
0.0
0.0
User Avatar
See private message.
$55.25 USD in 14 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$212.50 USD in 14 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
5.0
25
Member since Sep 16, 2001

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.