English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am posing the problem as a puzzle below, but the actual problem's wording is "Sort 5 numbers in 7 comparisons":

There are five balls of equal sizes, but different weights and different colours. You can identify each ball uniquely based on their colours, but not by their weights. You can assume that no two balls have the same weight.

You have a weighing scale ("pan-balance") that lets you put one ball on each side and lets you determine which is heavier and which is lighter.

Using the weighing scale at most SEVEN times (i.e., you compare any 7 pairs for their relative weights), arrange the five balls in increasing order of their weights.

As an example, you can sort 3 numbers in at most 3 comparisons, i.e., you need no more than 3 comparisons, but it could be done in 2 (only if you are lucky).

2006-09-08 08:28:07 · 5 answers · asked by kali 1 in Education & Reference Trivia

5 answers

Since there are only 5 balls, lets label them 1-5
Say they are these weights
1 is 3.5lb
2 is 3.8lb
3 is 3.7lb
4 is 3.4lb
5 is 3.6lb
This is kinda random
1st weigh 1 and 2 result 2 is heavier
2nd wegh 3 and 4 result 3 is heavier
now weigh the two heavier balls
3rd weigh 2 and 3 result 2 is heavier
now weigh the two lighter balls
4th weigh 4 and 1 result 1 is heavier
now you know that the order is lightest to heaviest is 4 1 3 2
Next, you do a binary search type weighing, start in the middle and 5th weigh 5 against 3, three is heavier so 5 goes before 3,
now 6th check if 5 is heavier than 1, it is so it goes between 1 and 3,
You got away with 6 measurements, if 5 was lighter than 3 you would have had to measure it against 4.
Does that make sense?
5 weigh 1 and 3 result 2 is heavier
6 weigh

2006-09-12 08:12:11 · answer #1 · answered by Dennis K 4 · 0 0

22

2006-09-10 09:03:49 · answer #2 · answered by david w 5 · 0 0

uhhh... i'm not sure if this is what your asking but here's my answer: say you label the balls 1-7. then place ball number 1 on one side of the scale and ball number two on the other. make note of how much heavier or lighter it is compared to ball 1. do this for balls 2-6 and then you should have your answer... i think... idk... hope that helped! but doubt it did!

2006-09-08 12:58:59 · answer #3 · answered by Anonymous · 0 0

void bubbleSort_flag(int a[], int n) { int i, j, temp, flag; for(i=n-a million; i>0; i--) { flag = a million; for(j=0; i>j; j++) { if(a[j]>a[j+a million]) { flag = 0; temp = a[j]; a[j] = a[j+a million]; a[j+a million] = temp; } } //out this block at the same time as flag is real //i.e. inner loop finished no swaps, so the list is already taken care of if(flag) spoil; } }

2016-11-06 22:10:25 · answer #4 · answered by ? 4 · 0 0

what...........well that bowled me over.........what a load of balls.

2006-09-08 09:25:45 · answer #5 · answered by Sunseaandair 4 · 0 0

fedest.com, questions and answers