Free help with homework

Why join Brainly?

  • ask questions about your assignment
  • get answers with explanations
  • find similar questions

Describe an algorithm for finding both the largest and the smallest integers in a

finite sequence of integers in an array and count them how many comparison
operation are involved.



This Is a Certified Answer

Certified answers contain reliable, trustworthy information vouched for by a hand-picked team of experts. Brainly has millions of high quality answers, all of them carefully moderated by our most trusted community members, but certified answers are the finest of the finest.
Keep two variables, max and min and assign each of them as the first element of the array.
Traverse through the array and compare each element with max and min and update max and min accordingly: 
if(A[i] >max) max = A[i]
if(A[i] < min) min = A[i], where A is the array and i as an index.
This procedure would require 2 * n comparisions, where n is the length of the array.
0 0 0
The Brain
  • The Brain
  • Helper
Not sure about the answer?
Learn more with Brainly!
Having trouble with your homework?
Get free help!
  • 80% of questions are answered in under 10 minutes
  • Answers come with explanations, so that you can learn
  • Answer quality is ensured by our experts