write an algorithm to produce the sum of the largest two num

write an algorithm to produce the sum of the largest two numbers from a set of four numbers a,b,c,d.
write an algorithm to produce the sum of the largest two numbers from a set of four numbers a,b,c,d.
write an algorithm to produce the sum of the largest two numbers from a set of four numbers a,b,c,d.

Solution

Assuming that we have an algorithm to sort the 4 numbers, call it sort[a,b,c,d]

sort[a,b,c,d] results a list {A,B,C,D} of the same 4 numbers a,b,c,d in ascending order so that C and D are the second largest and largest numbers out of the list a,b,c,d

The required sum is then C+D where {A,B,C,D} is the output of sort[a,b,c,d]

 write an algorithm to produce the sum of the largest two numbers from a set of four numbers a,b,c,d. write an algorithm to produce the sum of the largest two n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site