Linked Questions
25 questions linked to/from Parsing an arithmetic expression and building a tree from it in Java
0 votes
1 answer
581 views
Perform arithmetic operations using elements in list [duplicate]
I need to perform arithmetic operations using the elements in a list. For example, if I have a list of elements [25, +, 5, -, 8, /, 4] how can I convert this as an arithmetic operation in the form 25+...
0 votes
2 answers
117 views
Separate numbers in math expression [duplicate]
I have a math expression stored as a String: String math = "12+3=15"; I want to separate the string into the following: int num1 (The first number, 12) int num2 (The second number, 3) String ...
0 votes
0 answers
77 views
Computing a large mixed equation in java [duplicate]
Say I'm given an expression like (1/2) + (3/4) + (5/8) + (2/10) + (3/2) + (10/1) How might I go about computing this expression as a float value in such a way that if the expression where to change ...
1 vote
0 answers
24 views
Tree Structure for Algrebra [duplicate]
Abstract We are creating an application where a user creates a formula with data sent in by labs. I am currently creating a heavily parsed string to determine if the numbers are variables, ...
93 votes
4 answers
88k views
Writing a parser like Flex/Bison that is usable on 8-bit embedded systems
I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. If I were writing this to run on my Linux box, I could use ...
17 votes
14 answers
110k views
conversion from infix to prefix
I am preparing for an exam where i couldn't understand the convertion of infix notation to polish notation for the below expression: (a–b)/c*(d + e – f / g) Can any one tell step by step how the ...
2 votes
2 answers
21k views
Create a binary tree from an algebraic expression
I have to create an arithmetic evaluator in Java. To do this I have to parse an algebric expression in binary tree and then calculate and return the result. So for the first step how can I parse an ...
8 votes
5 answers
8k views
Removing unnecessary/duplicates parentheses from arithmetic expressions using stack(s)
Write a program for finding duplicate parenthesis in a expression. For example : (( a + b ) + (( c + d ))) = a + b + c + d (( a + b ) * (( c + d ))) = (a + b) * (c + d) One approach that I am aware ...
-1 votes
3 answers
8k views
Java. How to evaluate a String expression? [duplicate]
I have a mathematical expression in the form of a String. String exp = "3 + 6 - 10 + 12 + 15"; Now how to calculate the result of this expression as we do with other mathematical expressions. Help ...
4 votes
1 answer
3k views
Binary Tree : Advantages of pre-order ,post-order traversals in Binary Tree?
Inorder traversal of a Binary Search Tree yields nodes in increasing order. But what advantages do pre order and post order traversals have on any binary tree? EDIT:What I mean by advantages is : "...
3 votes
3 answers
1k views
Splitting a maths expression in Java
I'm trying to split a simple mathematics expression from it's parenthesis For example : (8+(3(2+3)(4-1))) to separate in to little expressions like (2+3), (4-1), (3*5*3), and finally (8+45). I tried ...
0 votes
3 answers
2k views
Convert arithmetic string into double in Java
I have a program where the user inputs 6 doubles, and the program outputs every combination of operators that can go in-between the doubles as 1024 separate strings. Here are the first two results if ...
2 votes
2 answers
2k views
Evaluate logical expression at runtime
How do I go about evaluating logical expression like "VERB1 OR (VERB2 AND VERB3) OR (VERB4)" entered at runtime. VERB* are placeholder to evaluate certain conditions. For example, VERB1 might mean ...
0 votes
1 answer
2k views
Add and Subtract
I feel like I've tried everything, searched everything I know to search, and I've been working on this for about 6 classes now. I'm trying to make a program that accepts a string input like "6 + 6 -3+...
3 votes
2 answers
852 views
String.split() returns an array with an additional empty value
I'm working on a piece of code where I've to split a string into individual parts. The basic logic flow of my code is, the numbers below on the LHS, i.e 1, 2 and 3 are ids of an object. Once I split ...