Question: 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

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 segment

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!