Note that the “second largest number” is the numberthat is bigger than all the o
ID: 3611329 • Letter: N
Question
Note that the “second largest number” is the numberthat is bigger than all the other
numbers except one; equivalently, it is the element that issmaller than exactly one other
element. To ensure that this definition works, you may assumethat there are at least two
elements in the array, and that all the array elements aredistinct. For example, if the array
contains the following 6 numbers (i.e. n = 6):3, -2, 4, -6, 7, 1; then the second largest
number is 4, which is smaller than 7 but larger than all theother elements.
The prototype of your function must be:
int secondLargest (int* A, int n)
Here, A is the array of integers andn is the number of elements in that array.This
function will find and return the second largest element amongthe n elements of the
array A.
Note: You are not allowed to change the contents of thegiven array. Moreover, you are
also not allowed to make a copy of the array’selements.
Hint# 1: You may need at least one helper function.
Hint# 2: Exactly one number is larger than the secondlargest number.
Explanation / Answer
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.