Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

What's the best gift you've ever received?

Answered: 1 week ago