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, 22.06.2019 01:00
Ap practice - performance task response the ap create performance task asks you to write about an abstraction that you developed and wrote into your code. most of the time that means identifying a function or procedure you wrote to "manage complexity" in your program. here is the actual prompt from the create performance task: 2d. capture and paste a program code segment that contains an abstraction you developed individually on your own (marked with a rectangle). this abstraction must integrate mathematical and logical concepts. explain how your abstraction manage the complexity of your program. (must not exceed 200 words) below is a segment of code from an "under the sea" program with a rectangle drawn around a portion of the code identifying an abstraction. imagine that you wrote this and are composing an ap response about how this abstraction manages complexity. (note: ignore the requirement that the abstraction integrate "mathematical and logical concepts" for this practice response. just write about managing complexity). explain how the abstraction marked with the rectangle in the code above manage complexity of this program. write your response here submit
Answers: 2
question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
question
Computers and Technology, 23.06.2019 02:30
How to launch an app: steps to be successful? launching an app is a great idea, but it’s not that easy as we supposed to think. the majority of mobile applications don’t generate revenue because companies aren’t ready to be competitive. referring to our experience in successfully building and launching apps we hope to you omit these difficulties. we are going to talk about ideas, marketing, testing your product, its development, distribution and support. you will learn 8 product launch stages to succeed.
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. a company is currently focusing on creating specific management goals for itself. which level of maturity is the company demonstrating under the sse_ccm framework? a. performed informally b. planned and tracked c. quantitatively controlled d. well-defined e. continuously improving
Answers: 2
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
Questions on the website: 13722367