Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 06:30, scoutbuffy2512
On early television stations, what typically filled the screen from around 11pm until 6am? test dummies test patterns tests testing colors
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, meijorjay94p2u2zy
Apart from confidential information, what other information does nda to outline? ndas not only outline confidential information, but they also enable you to outline .
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, zlittleton2008
Which feature of a blog to restore and retrieve older post
Answers: 3
image
Computers and Technology, 24.06.2019 13:00, naomirice24
In a heat transfer course, we can derive the equation for the temperature distribution in a flat rectangular plate. in this example, we will look at a plate at steadystate with three sides being held at t1, and one side held at t2. the temperature for any location on the plate, t(x, y), can be calculated by where create a function (prob3_5) that will take inputs of vectors x and y in feet, scalar n, scalars l and w in feet and scalars t1 and t2 in degrees fahrenheit. it will output a matrix t which is the temperature of each x and y locations. t will have the number of columns equal to the number of elements in x and rows equal to the number of elements in y. though this can be done without loops (perhaps more efficiently), your program must use a nested loop.
Answers: 2
Do you know the correct answer?
An algorithm will be used to identify the maximum value in a list of one or more integers. Consider...

Questions in other subjects: