Question 11 An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two versions of the algorithm below. Algorithm I: Set the value of a variable max to...


Question 11<br>An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two versions of the algorithm below.<br>Algorithm I: Set the value of a variable max to - 1. Iterate through the list of integer values. If a data value is greater than the value of the variable max, set max to the data value.<br>Algorithm II : Set the value of a variable max to the first data value. Iterate through the remaining values in the list of integers. If a data value is greater than the value of the variable max, set max<br>to the data value.<br>Which of the following statements best describes the behavior of the two algorithms?<br>A<br>Both algorithms work correctly on all input values.<br>В<br>Algorithm I always works correctly, but Algorithm II only works correctly when the maximum value is not the first value in the list.<br>Algorithm Il always works correctly, but Algorithm I only works correctly when the maximum value is greater than or equal to - 1.<br>D<br>Neither algorithm will correctly identify the maximum value when the input contains both positive and negative input values.<br>

Extracted text: Question 11 An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two versions of the algorithm below. Algorithm I: Set the value of a variable max to - 1. Iterate through the list of integer values. If a data value is greater than the value of the variable max, set max to the data value. Algorithm II : Set the value of a variable max to the first data value. Iterate through the remaining values in the list of integers. If a data value is greater than the value of the variable max, set max to the data value. Which of the following statements best describes the behavior of the two algorithms? A Both algorithms work correctly on all input values. В Algorithm I always works correctly, but Algorithm II only works correctly when the maximum value is not the first value in the list. Algorithm Il always works correctly, but Algorithm I only works correctly when the maximum value is greater than or equal to - 1. D Neither algorithm will correctly identify the maximum value when the input contains both positive and negative input values.

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here