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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:00
The first screen you see when you open word2016 what is called?
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
2. fluorine and chlorine molecules are blamed fora trapping the sun's energyob forming acid rainoc producing smogod destroying ozone molecules
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
Refer to the figure and match the theorem that supports the statement.οΏΌ1.if chords are =, then arcs are =.if bc = de, then arc bc = arc de2.if arcs are =, then chords are =.if arc bc = arc de, then bc = de3.diameters perpen
Answers: 3
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
question
Social Studies, 05.05.2020 07:05
question
Mathematics, 05.05.2020 07:05
question
Mathematics, 05.05.2020 07:05
question
English, 05.05.2020 07:05