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
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?
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 of i to 2 While (i less than or equal to n) do If Ai > largest so far then Set largest so far to Ai Set location to i Add 1 to the value of i End of the loop Print out the values of largest so far and location
is the idea that any random set of numbers can be plugged into this algorithm and worked??
Step 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