brendancrow6764 brendancrow6764
  • 27-10-2022
  • Computers and Technology
contestada

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.

Respuesta :

tonb
tonb tonb
  • 27-10-2022

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

Explanation:

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

Answer Link

Otras preguntas

Tectonic plates can include
2x + 5y = 0 x - 5y = -15
red blood cells are able to maintain homeostasis because they are bathed in blood, which is what to the fluid in the cells themselves?
What is the percentage of people who held most of America's wealth in 1900
what is the greatest common factor of 38 and 59
How do you simplify a square root with exponents and vareables
Which inequalities are true? Choose all answers that are correct. A. –9 < –6 B. –7 > –4 C. 11 > –12 D. 15 < –10 E. –15 > –4
What are all the factors of 27
how can you change linear equation in form ax+by=c to y=mx+b form and vice versa
What is the solution to the system of equations? 4x+y=2 x-y=3