Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Do the following program in c++ or java just pick one. C++ program that generates random arithmetic expressions over Z3 : #include #include #include #include
Do the following program in c++ or java just pick one.
C++ program that generates random arithmetic expressions over Z3 :
#include#include #include #include using namespace std; string rand_gen_z3(int); int main(){ int N = 1000; string s = rand_gen_z3(N); cout Java program that generates random arithmetic expressions over Z3:
import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) { int m = 100; System.out.println(rand_gen_z3Exp(m)); System.exit(0); } public static String rand_gen_z3Exp (int n){ if (nWrite a non-recursive program using a stack that evaluates arithmetic expressions over the set Z3 10, 1, 2). Assume that the expressions consist of operands from Z3 only, parentheses, and three operations, 3, 3 and &3, which represent the common arithmetic operations +,,* modular 3, in that order. For examples, 2 3 1 (2 + 1) mod 3 0 and 1 ?3 2 2-(1-2 * 2) mod 3-0. Note that like regular arithmetic operations + and-, the first operands of operations 3 and 3 can be omitted if they are 0's appearing as the first tokens of an expression or right after a "(". For examples, 3 2 (-2) mod 3-1 2 3 (O3 1) (2+(-1)) mod 3 1, and 31 +1 mod 3-1. Analyze the running time of your algorithm in terms of the input size n, which in this case is the number of symbols in the logical expression given as the input. Run your program on 3 randomly generated arithmetic expression over containing at least 100, 1000 and 10000 symbols to verify your running time analysis result. Z. Feel free to use common symbols +,-and * to represent?3, ?3 and ?? in that order, for the easiness of programming. You should also assume the following operator precedence: (), 3, 3, and 3, where 3, and 3 are considered having the same priorities Note: We now allow 3 and 3 to be "unary" serving as the sign symbol if they are the first operations of an expression or immediately after a (.So you need to think about what modifications need to be made on the stack-based algorithm for evaluating expressions in order to correctly handle expressions containing unary 3 and 3. You may use the following attached programs to randomly generate arithmetic expressions over Z3 and test cases to verify the correctness of your program Program for generating random arithmetic expressions over Z3 Write a non-recursive program using a stack that evaluates arithmetic expressions over the set Z3 10, 1, 2). Assume that the expressions consist of operands from Z3 only, parentheses, and three operations, 3, 3 and &3, which represent the common arithmetic operations +,,* modular 3, in that order. For examples, 2 3 1 (2 + 1) mod 3 0 and 1 ?3 2 2-(1-2 * 2) mod 3-0. Note that like regular arithmetic operations + and-, the first operands of operations 3 and 3 can be omitted if they are 0's appearing as the first tokens of an expression or right after a "(". For examples, 3 2 (-2) mod 3-1 2 3 (O3 1) (2+(-1)) mod 3 1, and 31 +1 mod 3-1. Analyze the running time of your algorithm in terms of the input size n, which in this case is the number of symbols in the logical expression given as the input. Run your program on 3 randomly generated arithmetic expression over containing at least 100, 1000 and 10000 symbols to verify your running time analysis result. Z. Feel free to use common symbols +,-and * to represent?3, ?3 and ?? in that order, for the easiness of programming. You should also assume the following operator precedence: (), 3, 3, and 3, where 3, and 3 are considered having the same priorities Note: We now allow 3 and 3 to be "unary" serving as the sign symbol if they are the first operations of an expression or immediately after a (.So you need to think about what modifications need to be made on the stack-based algorithm for evaluating expressions in order to correctly handle expressions containing unary 3 and 3. You may use the following attached programs to randomly generate arithmetic expressions over Z3 and test cases to verify the correctness of your program Program for generating random arithmetic expressions over Z3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started