Question: Question: Write an algorithm that finds the m smallest numbers in a list of n numbers. < < in simple java pseudocode >> ex: if

Question: Write an algorithm that finds the m smallest numbers in a list of n numbers.

<< in simple java pseudocode >>

ex:

if S={53, 8, 17, 8, 90, 5, 18, 17, 663, 91} n=10, then

The smallest m numbers when m=1 is {5}

The smallest m numbers when m=2 is {5,8}

The smallest m numbers when m=3 is {5,8,17} not {5,8,8}

The smallest m numbers when m=4 is {5,8,17,18} not {5,8,8,17} neither {5,8,17,17}

etc.

Avoid printing repeated numbers

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!