Question: Find Largest Algorithm Get a value for n, the size of the list Get values for A1, A2, ... An , the list to be
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 <= n ) do if A1 > 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?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
