subject

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.

B) Algorithm I always works correctly, but Algorithm II only works correctly when the maximum value is not the first value in the list.

C) Algorithm II 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.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, loveworld3798
When working with a team you should always do the following, except? question 3 options: be dependable and trustworthy be sensitive to others feelings do your fair share critique members of the group
Answers: 2
image
Computers and Technology, 22.06.2019 11:10, golderhadashaowtatz
Which are not examples of chronic or persistent stress? moving
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, kodak0531
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
image
Computers and Technology, 24.06.2019 08:30, trashellyoung
Why might you choose to create a functional resume
Answers: 1
You know the right answer?
An algorithm will be used to identify the maximum value in a list of one or more integers. Consider...

Questions in other subjects:

Konu
Chemistry, 12.12.2019 06:31