Logo Passei Direto
Buscar
Material

Prévia do material em texto

Chapter 1.2, Problem 3E Step-by-step solution Step 1 of 2 Finding the second largest and largest value in an array Consider an array of n integers. Traverse the array and keep track of the largest as well as second largest value in the traversed array. As we move further and if we find the value larger than second largest then we will update our largest value as well as second largest value accordingly. Here, Input parameter is (array of integers) and Output parameters are second_large, the second largest value and large, the largest value in the array. Step 2 of 2 Algorithm: Finding the second largest and largest values in an array. array_max(s) = //will assigns first value to large second_large = s[2] while(i

Mais conteúdos dessa disciplina