Question: C++ array sorting problem. we are going to take N numbers and a k value from the user and sort them. we will return kth

 C++ array sorting problem. we are going to take N numbers

C++ array sorting problem. we are going to take N numbers and a "k" value from the user and sort them. we will return kth number to the user. Do it this way: First, store the first k numbers in array. Then, sort this array in decreasing order. Read the rest of the numbers one by one -- Ignore if it is smaller than the number at kth position --otherwise, insert it in its correct position and shift the remaing numbers (the number at the kth position will be thrown away) Return the number at index k-1 of the array

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!