Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question in computer science For the final set of three balls, we simply repeat this: put one ball off to the side and weigh two.
Question in computer science
For the final set of three balls, we simply repeat this: put one ball off to the side and weigh two. Pick the heavier of the two. Or if the balls are the same weight, pick the third one.
Algorithm Approaches
If you're stuck, consider applying one of the approaches for solving algorithm questions starting on page Brainteasers are often nothing more than algorithm questions with the technical aspects removed. Base Case and Build and Do It Yourself DIY can be especially useful.
Additional Reading: Useful Math pg
Interview Questions
The Heavy Pill: You have bottles of pills. bottles have gram pills, but one has pills of weight grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once.
Hints: # # # #
Chapter Math and Logic Puzzles
Basketball: You have a basketball hoop and someone says that you can play one of two games. Game : You get one shot to make the hoop.
Game : You get three shots and you have to make two of three shots.
If is the probability of making a particular shot, for which values of should you pick one game or the other?
Hints:# # # #
Dominos: There is an chessboard in which two diagonally opposite comers have been cut off. You are given dominos, and a single domino can cover exactly two squares. Can you use the dominos to cover the entire board? Prove your answer by providing an example or showing why it's impossible
Hints: # #
pg
Ants on a Triangle: There are three ants on different vertices of a triangle. What is the probability of collision between any two or all of them if they start walking on the sides of the triangle? Assume that each ant randomly picks a direction, with either direction being equally likely to be chosen, and that they walk at the same speed.
Similarly, find the probability of collision with ants on an vertex polygon.
Hints: ## #
Jugs of Water: You have a fivequart jug, a threequart jug, and an unlimited supply of water but no measuring cups How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible.
Hints: # # #
BlueEyed Island: A bunch of people are living on an island, when a visitor comes with a strange order: all blueeyed people must leave the island as soon as possible. There will be a flight out at : pm every evening. Each person can see everyone else's eye color, but they do not know their own nor is anyone allowed to tell them Additionally, they do not know how many people have blue eyes, although they do know that at least one person does. How many days will it take the blueeyed people to leave?
Hints: # # # #
The Apocalypse: In the new postapocalyptic world, the world queen is desperately concerned about the birth rate. Therefore, she decrees that all families should ensure that they have one girl or else they face massive fines. If all families abide by this policythat is they have continue to have children until they have one girl, at which point they immediately stopwhat will the gender ratio of the new generation beAssume that the odds of someone having a boy or a girl on any given pregnancy is equal. Solve this out logically and then write a computer simulation of it
Hints:# # ## #
CrackingTheCodingInterview.comth Edition
Chapter Math and Logic Puzzles
The Egg Drop Problem: There is a building of floors. If an egg drops from the Nth floor or above, it will break. If it's dropped from any floor below, it will not break. You're given two eggs. Find N while minimizing the number of drops for the worst case.
Hints: # # # # # # #
pg
Lockers: There are closed lockers j a iallway. A man begins by opening all lockers. Next, he closes every second locker. Then, on his th Ird pass, he toggles every thiralocker closes it if it is open or opens it if it is closed This process continues for passes, such that on each pass the man toggles every ith locker. After his th pass in the hallway, in which he toggles only locker
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started