Here’s a puzzle. You have six blocks. One of them weighs more than the other. You have a scale but you can only use it twice. Find the heaviest one.
(a) Write down your process as an algorithm.
(b) What search is this like?
(a) 1. Measure two of the blocks on one side and two of the blocks on the other. If the scale balances go to 3, if not go to 2.
2. Take the two blocks from the heavier side of the scale and weigh them against each other, the heavier of the two is the heaviest block.
3. Take the two blocks you didn’t weigh, and weigh them against each other, the heavier of the two is the heaviest block.
(b) This is like binary search, where the set of things to search through is repeatedly split till an answer is found.
Computer Science & Information Technology