Ask Question
28 December, 19:25

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")

+4
Answers (1)
  1. 28 December, 21:52
    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?
Find 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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers