Coin Problem
You are given 9 gold coins that look identical. One is
counterfeit and weighs a bit greater than the others, but
the difference is very small that only a balance scale can
tell it from the real one. You have a balance scale that
costs 25 USD per weighing.
Give an algorithm that finds the counterfeit coin with as
little weighting as possible. Of primary importance is that
your algorithm is correct; of secondary importance is that
your algorithm truly uses the minimum number of weightings
possible.
HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!
Answer Posted / pawan jain
1. Divide the coins in 3 groups of 3 coins each
2. Put 2 groups in the weighing scale
3a. If both the groups weigh equal
1. Pick 2 coins from the 3rd group and put in weighing scale
2. If they weigh equal, the 3rd coin is counterfeit.
Else the coin which weigh more is counterfeit
3b. If they do not weigh equal, pick the group with more
weight and do steps 3a1 and 3a2.
Is This Answer Correct ? | 40 Yes | 13 No |
Post New Answer View All Answers
Question 1: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date. *This Should Be Done IN C++
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
Create a program to read two random data set in two files named data1.txt and data2.txt manifold contains integer numbers, whereas data2.txt file contains the float type numbers. Simpanlahmasing each into 2 pieces of data that is an array of type integer array and an array of type float, then calculate the average numbers in the second array.
how to diplay a external image of output on winxp by using c & c++,
write a program that reverses the input number of n.Formulate an equation to come up with the answer.
write a program that reads a series of strings and prints only those strings begging with letter "b"
Write a (n) algorithm that sorts n distinct integers, ranging in size between 1 and kn inclusive, where k is a constant positive integer. (Hint: Use a kn-element array.)
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
Code for Method of Handling Factorials of Any Size?
write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150
write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.
3. Program to find the Sum of give series. a. (1)+(1+2)+(1+2+3)+(1+2+3+4)+……………………………….. b. 1/1+1/9+1/25+1/49+……………...
Write a simple encryption program using string function which apply the substitution method.
write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation
solve the problem in the programming language C++"if a five digit number is input through the keyboard.Write a program to calculate the sum of its digits(hint: use the modulus operator)