Question: Write a function which returns the sum of the 2 largest integers in an array. You are not allowed to sort the array. int SumTwoLargest(int

Write a function which returns the sum of the 2 largest integers in an array. You are not allowed to sort the array.

int SumTwoLargest(int *data, int lengthOfData) // if using C++

Check your results with the following data sets

10, 5, 10 should return 20 10, 5, 15 should return 25 5, 10, 20 should return 30 5, 10, 10 should return 20 -5, -10, -1 should return -6 15, 10, 0 should return 25 10, 5, 7 should return 17 10 should throw insufficient data exception

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!