Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(5 marks) Looking at the Find Largest Algorithm as described in figure 2.14, if the numbers in the list were not unique, would the algorithm
(5 marks) Looking at the Find Largest Algorithm as described in figure 2.14, if the numbers in the list were not unique, would the algorithm report the first or the last occurrence of the largest number if it occurred several times? Explain your answer.
FIGURE 2.14 Get a value for n, the size of the list Get values for A, AA the list to be searched Set the value of largest so far to Set the value of location to 1 Set the value of i to2 While (is n) do If A, > largest so far then Set largest so far to A Set location to i Add 1 to the value ofi End of the loop Print out the values of largest so far and location Stop Algorithm to find the largest value in a listStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started