# 2nd smallest number puzzle

963.2K Views

There is 38 numbers. What is the least number of comparison needed to find the 2nd smallest out of them?

SherlockHolmes Expert Asked on 11th December 2017 in

Answer: 52 comparisons which is also the worst case

Here’s how the algorithm works:

1. Divide the 38 numbers into pairs, and find the smallest number in each pair. This takes 19 comparisons.
2. Take the 19 smallest numbers and pair them up again, finding the smallest number in each pair. This takes 18 comparisons.
3. Take the 9 smallest numbers and pair them up again, finding the smallest number in each pair. This takes 8 comparisons.
4. Take the 5 smallest numbers and pair them up again, finding the smallest number in each pair. This takes 4 comparisons.
5. Take the 3 smallest numbers and pair them up again, finding the smallest number in each pair. This takes 2 comparisons.
6. Take the 2 remaining numbers and find the smallest one. This takes 1 comparison.

Adding up the comparisons from each step gives us a total of 19+18+8+4+2+1=52 comparisons. However, in the worst case scenario, the two smallest numbers are always paired up in the last step.

Moshe Expert Answered on 27th February 2023.

• ## More puzzles to try-

• ### Whats going on riddle

A man leaves home, turns left, goes straight, turns left again, goes straight and turns left once more then returns ...Read More »
• ### Tuesday, Thursday what are other two days staring with T?

Four days are there which start with the letter ‘T‘. I can remember only two of them as “Tuesday , Thursday”. ...Read More »
• ### How will the logicians manage ?

A convention is held where all the big logicians are summoned. The master places a band on everyone’s forehead. Now ...Read More »
• ### Wire Cube riddle

Say you have some bendable wires (any number, any length). What is the minimum number of solder connections needed to ...Read More »
• ### Ninety One Riddle

Below equation is true. 8 + 8 = 91 How ?Read More »
• ### Box in the Carton

John can place six large boxes or nine small boxes into a carton. Can you find out in how many ...Read More »
• ### Mechanical Computer riddle

The Puzzlefry mechanical computer is a very sensitive device, it consists of interlocked toothed gear cogs. The largest Cog has ...Read More »
• ### Transport Puzzle

A man transports a fox, a duck and corn in a boat. The boat is only capable of transporting himself ...Read More »
• ### Stone and Eatable

Tell me the Hindi name of a Vegetable which if we remove 1st word will become a precious Stone and ...Read More »
• ### China and Japan

Why do Chinese men eat more rice than Japanese men do ?Read More »
• ### Wind Blows South and then North

Do you know of a place where the wind blows south and then suddenly shifts direction towards the north?Read More »
• ### Cards Probability Puzzle

Andrew is shuffling a pack of 54 cards in total and after some time, he takes out a joker card. ...Read More »
• ### What is it that no man wants

What is it that no man wants, but no man wants to lose?Read More »
• ### Time Measurement

How will you measure 15 minutes using two hourglasses of 7 minutes and 11 minutes respectively?Read More »
• ### Find hidden words Resturant picture puzzle

Find 6 hidden words in this ResturantRead More »
• ### What do you see in the given picture?

What do you see in the given picture?Read More »
• ### Table to eat

What kind of table is good for you to eat?Read More »
• ### Sequence Puzzle

There is this one man who killed his mother, was born before his father and married over 100 women without ...Read More »
• ### Tool of War

Helps to conquer, helps to protect. Sometimes threaten, sometimes defeat. Sometimes grows, sometimes shrinks. Results our downfall, results our success. ...Read More »
• ### How will you do that?

You are standing next to three switches. You know these switches belong to three bulbs in a room behind a ...Read More »