riderchap
BAN USER- 0of 0 votes
AnswersWrite an SQL query to select the nth row from a table.
- riderchap
I asked the interviewer that, can I assume say the nth record is based on a primary/unique key column or any column, he said no, the question is just select the nth row.| Report Duplicate | Flag | PURGE
PayPal Database - 0of 0 votes
AnswersA bag contains 5 coins. Four of them are fair and one has heads on both sides. You randomly pulled one coin from the bag and tossed it 5 times, heads turned up all five times. What is the probability that you toss next time, heads turns up. (All this time you don't know you were tossing a fair coin or not).
- riderchap| Report Duplicate | Flag | PURGE
SIG (Susquehanna International Group) Brain Teasers
I was exposing that your answer is indeed based on the assumption that each time you are pulling a coin from the bag. But that is not the case here.
The result of a toss doesn't depend on previous tosses if you know what you are tossing. If I am tossing a fair coin the probability of next head after 5 (or any number of) heads is 1/2. If that is a double headed the probability is 1. Here you don't know what you are tossing.
For a fair coin the probability of a head after 5 heads is 1/2 as we all know, and we can reach that solution by the same solution proposed by Gursharan.
P(6 heads in a row ) = 1/64
P(5 heads in a row ) = 1/32
P( Next head ) = P( Next head | 5 heads in a row)
----------------------------------
P(5 heads in a row )
But P( Next head | 5 heads in a row) = P(6 heads in a row )
P( Next head ) = P(6 heads in a row )
---------------------
P(5 heads in a row )
P( Next head ) = 1/64
---- = 1/2
1/32
For the problem given.
P(6 heads in a row ) = 17/80
P(5 heads in a row ) = 9/40
P( Next head ) = P( Next head | 5 head in a row)
----------------------------------
P(5 heads in a row )
But P( Next head | 5 head in a row) = P(6 heads in a row )
P( Next head ) = P(6 heads in a row )
---------------------
P(5 heads in a row )
P( Next head ) = 17/80
---- = 17/18
9/40
Imagine this, I have a fair coin in my hand and I got say 1000000000000000000 heads in a row, since its a fair coin I know the probability of next head is 1/2.
Now in the given scenario I got say 100 heads in a row, I don't know its fair coin or a double headed coin in my hand. At first (when we pulled the coin from the bag) there was a 4/5 chance that its a fair coin and 1/5 chance that its a double headed coin in my hand. But now since we saw 100 heads in a row there is 2^n/(4+2^n) = 2^100/(4 + 2^100 ) = 0.99999999999999999999999999999684 chance that its a double headed coin (see http://math.arizona.edu/~jwatkins/f-condition.pdf). Still do you think that the probability of next head is 3/5?
Where did you get the information about the "address operator"?
C++ ISO/IEC 14882:
$12: "The default constructor (12.1), copy constructor and copy assignment operator (12.8), and destructor (12.4) are special member functions. The implementation will implicitly declare these member functions for a class type when the program does not explicitly declare them,....."
This is not correct.
If what you are saying is correct, then the probability of two heads in two tosses is 3/5 * 3/5 = 9/25, right?
But the probability of two heads in two tosses should be calculated as (4/5 * 1/2 * 1/2) + (1/5 * 1 * 1) = 2/5.
Gursharan's comment explains the answer neatly.
I guess that, the key is the medical-scale and how it weighs, unless its balancing we are not weighing, if its stuck as heavier than the marked weight or as lighter as the marked weight we are not weighing.
This is what I think.
1. Keep one stone apart, call it #9.
2. Take four stones say (1,2,3 and 4 ), put them on the platform and balance their weight, (slide the slider to the mark). Measuring#1. Now unless we balanced the weight again we are not measuring.
3. Now remove all the four stones and put other four (5,6,7 and 8 ), now if the scale balances the heavier is #9.
4. If the scale is unbalanced and stuck as heavier go to step# 5, if the scale is unbalanced as lighter go to step# 8.
5. Place #1 on platform, still the balance beam wont move, it will be stuck as heavier.
6. Now remove #5, if the scale balances #5 is the heavier one.
7. If the scale is still stuck as heavier, place #2 then remove #6, if balanced #6 is the heavy one, else if still stuck as heavier, place #3 then remove #7 if balanced #7 is the heavy one else #8 is the heavy one.
8. Remove #5 from the platform, still the balance beam wont move, it will be stuck as lighter.
6. Now place #1, if the scale balances #1 is the heavier one.
7. If the scale is still stuck as lighter, remove #6 then place #2, if balanced #2 is the heavy one, else if still stuck as lighter, remove #7 then place #3, if balanced #3 is the heavy one else #4 is the heavy one.
This will not work. It will return 2 for the example given. Try it yourself.
This could work
int MinDepth(TreeNode *node)
{
if( node == 0 )
{
return 0;
}
int hL = MinDepth(node->left);
int hR = MinDepth(node->right);
if( (hL == 0) || (hR == 0) )
{
return max( hL, hR ) + 1;
}
return min( hL, hR ) + 1;
}
Repmarthahiggs71, Intern at Achieve Internet
Hi, I am Martha from Toledo, OH. Working with Top NYC consulting engineers by helping them design controls projects. Have ...
Repjacksonbetty625, Accountant at 247quickbookshelp
My work is specialized help, regardless of whether on the telephone, face to face, or distantly, identified with PC frameworks ...
Repcarmelalewis9, Area Sales Manager at AMD
I am fond of reading stories then reading articles which are all about a story of a beautiful nature and ...
RepBlakeRileyHomes, Analyst at Aristocrat Gaming
Blake Riley Homes is the leading interior designing and real estate home staging Orange County CA company.Our professional designs ...
Reppfisterruiz, Accountant at 247quickbookshelp
Door-to-door is a canvassing technique that is generally used for sales, marketing, advertising, evangelism or campaigning, in which I walk ...
Reppedrospencerp, Blockchain Developer at 247quickbookshelp
My name is Pedro and I am a 28 years old Title abstractor . I research all documents and activities affecting ...
>>"The comment above from RiderChap, which shows 3/5 * 3/5 for a two-heads toss would, expanded out, be:
- riderchap January 27, 2011[(4/5 * 1/2) + (1/5 * 1)]*[(4/5 * 1/2) + (1/5 * 1)]
But this brings in all kinds of cross terms, which don't seem to make much sense."
Yes, it does not make any sense. I put that to explain that 3/5 is not correct. I am sorry if my comment was misleading.
If I am getting all heads for 100000 tosses in a row, there is a greater chance that I pulled a two headed one from the bag, don't you think? So if the previous outcomes are given you need to consider that, it could give you (in the given question it will) a more accurate probability for what kind of coin is in your hand.
See http://math.arizona.edu/~jwatkins/f-condition.pdf