Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Anyone know how I can make the comparisons and write an optimized version? two, three and tour Boolean expressions. 20 points 3. Assume x, y
Anyone know how I can make the comparisons and write an optimized version?
two, three and tour Boolean expressions. 20 points 3. Assume x, y and z are integer variables. Verify that the code segment below always gives the correct output, then answer the question below. System , out: printin ("x, y and z are equal."); System out println ("Only x and y are equal."); System .out println ("Only y and z are equal.") System .out .. println ("Only x and z are equal." System .out . printin ("x, y and z are distinct. "); else (A) What will be the output of the code segment when 8, y 8 and z-7? [5 points) nF Kn At least how many comparisons will be made when this code segment is executed? Give values for the variables a, y and z when, this occurs. What would be the output of the code segment? [5 points] (B) At most how many comparisons will be made when this code segment is executed? Give values for the variables , y and z when this occurs. What would be the output of the code segment? (5 points] (C) (D) Explain why the code segment is ineficient by giving values for the variables , VL (E) Calculate the average number of comparisons per (F) Write an optimized version of the code segment that does not make an unnece (G) Calculate the average number of comparisons per branch of the optimized version y and z for which a relational expression is evaluated unnecessarily. [5 points above. [5 points] sary comparison. 5 points of the code segment that you wrote in 3.(F). [5 branch of the code segmentStep 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