Ask Question
25 July, 13:36

Find largest algorithm get a value for n, the size of the list get values for a1, a2, ... an, the list to be searched set the value of largest_so_far to a1 set the value of location to 1 set the value to i to 2 while (i largest_so_far then set largest_so_far to a1 set location to i add 1 to the value of i end of the loop print out the values of the largest_so_far and location stop question: if the numbers in our list were not unique and therefore the largest number could occur more than once, would the algorithm find the first occurrence? (select: true for "yes"; false for "no")

+2
Answers (1)
  1. 25 July, 16:19
    0
    The algorithm as written here will do nothing useful, as a1 is always being compared to a1. It will only print a1 and location 1.

    Step-by-step explanation:

    As intended to be written, the comparison is "greater than", so there will only be a change in "largest_so_far" when a greater value is found. A value that is the same will not result in any new output. The algorithm as intended will find the first copy of the largest value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Find largest algorithm get a value for n, the size of the list get values for a1, a2, ... an, the list to be searched set the value of ...” in 📙 Mathematics if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers