subject

An algorithm will be used to calculate the difference between the smallest and largest values in a list. For the list of [10, 3, 5, 6], it should calculate a difference of 7. There are two proposals for the algorithm:
Algorithm 1: Set minVal to the first value in the list and maxVal to the last value in the list. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal.
Algorithm 2: Set minVal to 1000 and maxVal to 0. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal.
Which of these statements are true about these algorithms?
I. Algorithm 1 does not work on lists where the smallest value is at the start of the list or the largest value is at the end of the list.
II. Algorithm 2 does not work on lists that contain all negative numbers or all numbers over 1000.
A. I only
B. II only
C. I and II
D. Neither I nor II
Include a justification for your choice.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:20
When developing a stakeholder matrix, the portfolio manager must look at the portfolio governance in order to complete the stakeholder analysis. in your own words, what is the role, interest and expectations of the governance?
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
When building customer relationships through email what should you not do? question 2 options: utilize proper grammar, spelling, and punctuation type in all capital letters use hyperlinks rather than attachments respond to all emails within 24 hours
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Gabe wants to move text from one document to another document. he should copy the text, paste the text, and open the new document highlight the text, select the cut command, move to the new document, make sure the cursor is in the correct location, and select the paste command select the save as command, navigate to the new document, and click save highlight the text, open the new document, and press ctrl and v
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
You know the right answer?
An algorithm will be used to calculate the difference between the smallest and largest values in a l...
Questions
question
Mathematics, 21.01.2021 22:10
question
Mathematics, 21.01.2021 22:10
question
Mathematics, 21.01.2021 22:10
question
History, 21.01.2021 22:10
Questions on the website: 13722359