Question: 5. Assume first and second are integer variables. if (first secondk first > third) System-out.print f(%d else if (second third) largest., first); is the System
5. Assume first and second are integer variables. if (first secondk first > third) System-out.print f("%d else if (second third) largest.", first); is the System . out.print f("%d is the largest. ", second); else System.out printf("id is the largest.",third) (A) what will be the output of the code segment when first = 8, second = 7 and third = 87(5 points] (B) At least how many comparisons will be made when this code segment is executed? Give values for the variables first, second and third when this occurs. What would be the output of the code segment? 5 points (C) At most how many comparisons will be made when this code segment is executed? Give values for the variables first, second and third when this occurs. What would be the output of the code segment? 5 points) Explain why the code segment is inefficient by giving values for the variables first second and third for which a Boolean expression is evaluated unnecessarily. [5 points) (D) (E) Calculate E, the average number of Boolean expressions evaluated per branch of F) Write an optimized version of the code segment that does not evaluate a Boolean G) Write a modified version of the code segment in 5.(F) by adding a counter variable this code segment. [5 points) exression unnecessarily. [5 points num Bool Expr Eval whose value will always be the number of Boolean expressions evaluated after the code segment is executed. 5 points (H) Calculate the average number of Boolean expression evaluated per branch of the optimized version of the code segment that you wrote in 5.(F). [5 points Duncan:CSC 1350:F 17 3
Step by Step Solution
There are 3 Steps involved in it
To solve the problem efficiently lets break it down step by step Given Code The code snippet looks like this with some corrections for clarity java if ... View full answer
Get step-by-step solutions from verified subject matter experts
