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, 22.06.2019 18:00
What is the first view you place in your drawing?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
What is the primary difference between the header section of a document and the body? a. the body is displayed on the webpage and the header is not. b. the header is displayed on the webpage and the body is not. c. the tag for the body is self-closing, but the tags for the headers must be closed. d. the tag for the header is self closing, but the tag for the body must be closed.
Answers: 3
question
Computers and Technology, 23.06.2019 21:30
Enzo’s balance sheet for the month of july is shown. enzo’s balance sheet (july 2013) assets liabilities cash $600 credit card $4,000 investments $500 student loan $2,500 house $120,000 mortgage $80,000 car $6,000 car loan $2,000 total $127,100 total $88,500 which expression finds enzo’s net worth?
Answers: 1
question
Computers and Technology, 24.06.2019 19:30
Which phrase is the best definition of a pivottable a a table containing data that is organized horizontally b a table used to calculate financial pivot values c a tool used to summarize data d a table containing specific formatting
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
Questions on the website: 13722363