79.4k views
2 votes
describe an algorithm that locates the first occurrence of the largest element in a finite list of integers, where the integers in the list are not necessarily distinct.

1 Answer

5 votes

Answer:

initialize variable "position" with first location in th elist

initialize variable "largest" with value at first location

loop over all list positions:

at each position, check if value there is larger than "largest" if so:

update position

update largest

Step-by-step explanation:

This is a linear algorithm, meaning the time it takes to complete grows linearly with the size of the list.

User Daryll
by
4.8k points