, , , ,

[SOLVED] Cs 3345 project 1: applications of queues/stacks

$25

File Name: Cs_3345_project_1__applications_of_queues_stacks.zip
File Size: 452.16 KB

5/5 - (1 vote)
5/5 – (1 vote)

In this project, you will be using stacks to parse/evaluate arithmetic expressions.This is an individual project. Do not share your work with others. Do not refer or  use any material from external sources other than the materials provided in the class and in the references below..ANY ACT OF PLAGIARISM WILL BE REPORTED.Read this project specification carefully.Algorithms to parse infix expressions was discussed in the class. Algorithms to evaluate postfix expressions, and to evaluate expression tree will be discussed in the class next week.Use ArrayDeque from the Java library for the stacks.  Do not code your own stack.Starter code Expression.java  and few testcases are provided in the box folder.Add additional fields, methods, classes as needed.Do not change the name of the class or signatures of public methods.Your code should be well structured and commented properly. Please follow format specified in Javadoc.10 points are allocated for style and comments.The following methods need to be completed.  No error checking is required.If the expressions passed are valid, then the methods should work correctly.Given invalid expressions, your program can return wrong values, print error messages,or throw exceptions.Method to convert String to a Token:The string holds exactly one token, with no extra spaces before or after the token.Possible tokens are:    Operators: PLUS (“+”), TIMES (“*”), MINUS (“-“), DIV (“/”), MOD (“%”), POWER (“^”)    Parentheses: OPEN (“(“), CLOSE (“)”)    Number: NUMBER (any valid string that represents an integer)        Assume that if a token is not an operator or a parenthesis, then it is a number.    Use Long.parseLong(tok) to convert string to long.    Signature: static Token getToken(String tok) {  … }    Tokens have a field “priority” that can be used to store precedence of operators during parsing.    Precedence: {^} > {*, /, %} > {+, -}.  Assume that all operators are left associative.    Assign your own values to priority of tokens.  Field “number” is used to store    the value of NUMBER token.  A token “NIL” is defined for internal use and    it does not correspond to any token in the expressions.  It is a convenient token to    mark bottom of stack.Method to convert an infix expression given as a list of tokens into an expression tree:    Given an infix expression as a list of tokens, return its corresponding expression tree.    Signature: public static Expression infixToExpression(List<Token> exp) { … }Method to convert an infix expression into a postfix expression:    Given an infix expression as a list of tokens, return its equivalent postfix expression.    Signature: public static List<Token> infixToPostfix(List<Token> exp) { … }Method to evaluate a postfix expression:    Given a postfix expression, evaluate it and return its value.    Signature: public static long evaluatePostfix(List<Token> exp) { … }Method to evaluate an expression tree:    Given an expression tree, evaluate it and return its value.    Signature: public static long evaluateExpression(Expression tree) { … }Submit the completed Expression.java file on elearning.References:1. https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/ArrayDeque.html2. https://docs.oracle.com/javase/tutorial/collections/index.html3. https://en.wikipedia.org/wiki/Javadoc

Shopping Cart
[SOLVED] Cs 3345 project 1: applications of queues/stacks[SOLVED] Cs 3345 project 1: applications of queues/stacks
$25