Alice and Bob are each sorting out a deck of standard poker cards (13 cards in each suit, 4 suits per deck). They have each adopted a different approach to sorting the cards into order (ordered ascending by value within suits, with the suits in order hearts, spades, diamonds, clubs).
Alice looks through the deck until she finds the ace of hearts, then sets it aside and starts over. Then she looks for the two of hearts until she finds it, then sets it aside. She continues in this way until she's put the cards in order.
Bob first goes through the entire deck and sorts every card into piles based on suit (4 piles). After he's finished, he picks up the pile of hearts and proceeds to use Alice's method (namely, he looks for the ace, then the two, etc., each time moving them to the correct pile when finished).
Assuming the cards are ordered randomly, in what order would we expect them to finish?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Empirical evidence demonstrates that the same distribution of cards ... The results are Alice <= Bob ... but it depends on your distribution (of Cards)...
The main reason is the following:
When Bob is in the first stage (before applying the method alice) let X the final distribution of the cards to that stage ...
Now if the distribution was initially X. .. but X is invariant to the method of bob ... therefore ...
Alice and Bob ... would begin at the same point ... return results at the same time ...
But this situation (or some similasres) are less likely than the genral case where Bob wins by 1 or 2 step ...
In spite of all ... the statistical proof return results that most of the times Bob won 1 or 2 steps ... and some tied it ... but the final answer is ... none of the above ...
I think it's easy to understand the implementation perform ... is made to fast ... but it's easy to understand ... and meets the objective ... Regards ...
(sorry my english please)
https://cloud.sagemath.com/projects/cb5c6d0e-ad46-4b1e-8e3f-8ff6fc13d2f2/files/Empirical%20Evidence.sagews
Log in to reply
No, the statistical proof (read: code that I made) suggests that Bob takes approximately 30-50% of the number of steps that Alice takes.
I cannot see how you determine that they return results at the same time from the fact that the initial distribution takes the same time for Bob to order into suits.
Log in to reply
The Bob method have two stages...
1 - Initial 2 - The alice method
Let be X the distribution of cards, at the stage 1. of the bob method
Now let be X (the same of above), the initial distribution of cards for Bob and Alice
Bob. 1- Initial X -> 52 Inecesari Steps... (the cards are invariant to the forst stage of the bob method) 2 - Let be S the staps for Apply de alice method...
Alice... 1- S steps...
Result: Alice < Bob (S < S + 52)
what you do not understand?
Strictly speaking the answer is "None of the Above"
Log in to reply
@Oscar Riveros – No, who says Bob must take the same number of steps as Alice? Bob only applies Alice's method, and that's for his individual 13-card piles; Alice applies her method to a 52-card pile.
Log in to reply
@Ivan Koswara – Bob is multitasking? Its method is necessarily equivalent ... if conditions I mention in the demonstration are met ...
Log in to reply
@Oscar Riveros – Have you tried making the code? I've checked by simulation myself. And you still haven't given your argument on why the methods are necessarily equivalent. Here's a rough sketch of why Bob should finish earlier.
Imagine each of them only needs to find one card. Given a n -card pile, you would expect to find the card averagely after n / 2 cards; this is just basic expected value.
Now you have to find all n cards (to sort cards, you have to find them). Thus you need to take 2 n + 2 n − 1 + … + 2 1 cards on average. This is equal to 4 n ( n + 1 ) cards.
Alice has a single 52-card pile. Bob has four 13-card piles. Plug them into the formula and figure out how many cards each person should take. Even adding the initial sorting by Bob (the 52 cards) still don't change that he finishes way faster than Alice.
Log in to reply
@Ivan Koswara – ♠ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
♥ [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
♦ [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]
♣ [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]
shuffle the cards!
[4, 5, 13, 9, 2, 7, 1, 6, 10, 3, 12, 11, 8, 25, 20, 22, 17, 14, 16, 26, 15, 24, 18, 21, 19, 23, 37, 38, 35, 36, 33, 30, 34, 39, 32, 29, 28, 27, 31, 47, 45, 52, 43, 41, 42, 44, 48, 49, 50, 46, 51, 40]
separated into stacks of 13
♠[4, 5, 13, 9, 2, 7, 1, 6, 10, 3, 12, 11, 8]
♥[25, 20, 22, 17, 14, 16, 26, 15, 24, 18, 21, 19, 23]
♦[37, 38, 35, 36, 33, 30, 34, 39, 32, 29, 28, 27, 31]
♣[47, 45, 52, 43, 41, 42, 44, 48, 49, 50, 46, 51, 40]
Now Bob... apply the first rage of method: result:
♠[4, 5, 13, 9, 2, 7, 1, 6, 10, 3, 12, 11, 8]
♥[25, 20, 22, 17, 14, 16, 26, 15, 24, 18, 21, 19, 23]
♦[37, 38, 35, 36, 33, 30, 34, 39, 32, 29, 28, 27, 31]
♣[47, 45, 52, 43, 41, 42, 44, 48, 49, 50, 46, 51, 40]
The same!!! but it took 52 steps to carry out this unnecessary task.
Now Bob apply the Alice method: bob, ordered the cards in N steps ... with the method (Alice)
It takes N + 52 steps...
An now alice... Alice Obviously, we take only N steps
Result...
Alice win for 52 steps...
The problem with your formula is that you are not considering the boundary conditions.
Log in to reply
@Oscar Riveros – Oh, I also notice that when you shuffle, you only shuffled each suit and then stacked the suits on top of another without shuffling them. Of course Alice will win here. Try the reverse permutation [51,50,...,0].
@Oscar Riveros – No, Alice doesn't sort the cards. Alice goes through all 52-card pile.
Log in to reply
@Ivan Koswara – it is a possible situation, a boundary condition.
Log in to reply
Assuming the cards are ordered randomly
You need to take account on all possible orderings due to this statement.
@Oscar Riveros – Oscar, doesn't Alice have to (on average) look at more cards before she finds the next card to put in the stack? In the example above, you didn't shuffle the suits together, but that would be a very unlikely ordering if the cards were random.
If we're going to look at arbitrary orderings of the cards, I can give you a different scenario: [ 52, 51, 50, ... 2, 1]. In this case, Alice will have to look through 51 wrong cards before she finds #1, 50 before she finds #2, etc. After he's sorted the cards into suits, however, Bob will only have to look through 12 cards to find #1, 11 to find #2, etc.
Obviously, in your scenario, sorting into suits was unnecessary (since the card were already ordered). However, in the case where the cards are in reverse order, it's quite helpful. The question asks what we would expect to happen, given a random deck. It's almost always possible to construct a non-random ordering that defeats the more general question.
Log in to reply
@Arron Kau – I already replied to all that ...
"This statement is erroneous, what is the probability that what I say above is correct?"
I think if we play Russian roulette ... I would survive, and you do not ...
I'm sorry but if you are estaff, is easier than deleting my account ... to try to defend the indefensible ...
@Arron Kau – Given that he has an incorrect interpretation and insists on it, the best way is just to leave him. (Compare to math: someone that doesn't accept an axiom (like 1+1=2) cannot be persuaded to do so; the best way is just to ignore him.)
Log in to reply
@Ivan Koswara
–
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." -
Stephen Hawking, (it's actually from Daniel J. Boorstin.)
Read this... (the books...) http://en.wikipedia.org/wiki/Principia_Mathematica
"Knowledge is the same for everybody, the opinions are for fools ..." - Me!!!
I'm really bored, please delete my account ... I'm tired ... very tired ...
too much taugh
correct
I do not understand, if we will talk about worst case that say Alice is arranging cards in her manner, so she starts with say heart, it is worst case means whatever card she is trying to get is at last....... means if she is looking for ace of heart it is at 52 position she took it out, now only 51 cards left, the second will be 2 of heart at 51 position of 51 cards so you can easily think that her way is 52+51+50+...........+1=26*53= 1378
Now Bob he is looking for any 13 cards of same suit say heart in first step, again worst case scenario...... all 13 cards of heart are the last 13 position, so first heart is at 52-13=39, means he will get all 13 cards at 40 position 40 13=520, then from these 39 cards he is searching for spade suit again all 13 of spades are at last 39-13=26 so he will all 13 spades at 27 position 27 13=351, similarly all diamond at 13 position 14 13=182and all clubs at 1 position so 13 total 520+351+182+13=1066 chances, now he will go for second round again worst case that is like Alice doing her job with 13 cards (13+12+..........+1)4 for 4 suits...(6 14+7)4=364 now 364+1066=1430>1378,,,because if Alice is finding Ace of heart at last then Bob Suit also have ace of heart at the bottom of suit.................means he is reversing his cards
means Bob is doing more work mathematically at same condition so how can he came first, because if this is the result for worst case and both are provided same kind of deck we have to assume both have same places of cards else question has no sense.................In both the case I DON'T UNDERSTAND THE ANSWER
We can use Asymptotic Analysis to figure out which one is quicker. In this method we try to come up with and assign a cost to the worst case scenario
Let v = # times we view a card.
CASE 1: In Alice's case, she looks at each card in the deck and determines if it's the one she is looking for. This is an example of Selection Sort.
Worst case scenario, she ends up looking through all the cards before she finds the correct one. In the initial step, she ends up looking through 52 cards. In subsequent steps, the number of cards she looks through is decreased by 1, since each time 1 card will be removed from the list.
v = 5 2 + 5 1 + ⋯ + 2 + 1 = 1 3 7 8
CASE 2: In Bob's case, he first sorts the deck into 4 piles by suit, then he performs the same operation as Alice did on each pile. The first part is an example of Bucket Sort. He is not concerned with order, he looks at each card and places it in the correct pile. In this case he will end up looking at each card just once to determine the pile it belongs in.
During the second part, like Alice did on the deck, he performs a Selection Sort on each pile. Each pile will have 13 cards. Worst case scenario he will have to look through all cards in their respective piles to find the correct card. And he will repeat that 4 times for each pile.
v B u c k e t = 5 2 v P i l e = 1 3 + 1 2 + ⋯ + 2 + 1 = 9 1 v = v B u c k e t + 4 ⋅ v P i l e = 5 2 + 4 ⋅ 9 1 = 4 1 6
Bob's method results in a smaller number of views. So theoretically, it is faster.
U can use logic.Bob's method is more efficient than Alice's
Empirical evidence demonstrates that the same distribution of cards ... The results are Alice <= Bob ... but it depends on your distribution (of Cards)...
The main reason is the following:
When Bob is in the first stage (before applying the method alice) let X the final distribution of the cards to that stage ...
Now if the distribution was initially X. .. but X is invariant to the method of bob ... therefore ...
Alice and Bob ... would begin at the same point ... return results at the same time ...
But this situation (or some similasres) are less likely than the genral case where Bob wins by 1 or 2 step ...
In spite of all ... the statistical proof return results that most of the times Bob won 1 or 2 steps ... and some tied it ... but the final answer is ... none of the above ...
I think it's easy to understand the implementation perform ... is made to fast ... but it's easy to understand ... and meets the objective ... Regards ...
(sorry my english please)
https://cloud.sagemath.com/projects/cb5c6d0e-ad46-4b1e-8e3f-8ff6fc13d2f2/files/Empirical%20Evidence.sagews
Alice goes through the deck systematically, and so the probability she finds each card she is looking for is approximately 5 2 ! 1 . This comes out to approximately 1 0 − 6 8 .
Bob, discounting his initial sorting, takes approximately 4 ( 1 3 ! 1 ) which comes out at approximately 1 0 − 1 0 .
Since there are significantly fewer permutations for Bob, his sorting must be quicker.
(Ok, ignore the math, but I stand by my logical reasoning xD)
Its just simple logic. It takes less time to go through the pile instead of going through entire deck.
For Alice : total time
= 52 + 51 + .....+ 2 + 1 = 26 * 53
For Bob: total time = 52 + forAllColor(13 + 12 + 11 +...+ 2 + 1)
= 52 + 4 * (13 * (13 + 1)/2)
= 52 + 4 * (13 * 7)
= 52 + 28 * 13
So bobTime < AliceTime
Actually , what Bob did , is little bit similar to the concept of divide and conquer algorithm . At first when Alice started sorting , he worked with all 52 cards whereas Bob divided that sorting problem into 4 smaller parts and solved them individually . Then , he merged 4 smaller problems into 1 to find the final solution . You can find out the worst case complexity of the procedure of both Bob and Alice . And then you will understand why Bob needed fewer time than Alice.
Step 1:
Suppose , there are n cards . So , if we want to work with all n cards , we may need to at most n cards if we want to find the desired card (it's the worst case) . And once we find the card with least value , next stage our worst case will be 1 less than n , n-1 . And next it will be n-2_then n-3 then n-4 ......... and so on . So, in that case at most c1 = 2 n ∗ ( n + 1 ) number of checking will be needed .
Step 2:
(i) At first we want to separate 4 different decks it is enough to check all n cards once . Here , complexity : n
(ii) Then , We can sort them individually by using Step 1: 4 times . Here , complexity : 4 ∗ ( 2 4 n ∗ ( 4 n + 1 ) )
(iii) At last , we can merge these 4 decks by only 4 operation .
So , that procedure will need at most c2 = n + ( 4 ∗ ( 2 4 n ∗ ( 4 n + 1 ) ) ) + 4 number of checking .
And if you calculate c1 and c2 , you will find that c1 will be always bigger than c2 for any n . So, Bob will need fewer time than Alice . That's how divide and conquer work's . And sorry for poor English :)
Lets consider the worst case: Lets say while going through the cards, each time a card is considered it consumes a 1 unit time. Therefore Alice will consume time 52+52+50+....1 = 1352. While Bob will sort the cards in suits in one 52 steps there after he needs to sort each suit in numbers which will take 13+12+11...1 time there his total time is 52+ 4(13+12+11...) =416 which is much smaller than Alice's.
No need to use calculation, the logic for this question is simply easy.
Well I think it goes this ways: Alice has to search for one card in the deck of 52 cards, then one card in the deck of 51 cards and so on.. This way the average number of steps are: 52/2 + 51/2 + 50/2 + ... = 689. Now Bob has do the same thing but in a different way. Initially Bob has to do 52 steps compulsorily to separate the deck suit wise. Now he has to find one card in suit of 13. The same way as with Alice avg. number of steps = 13/2 + 12/2 + 11/2 + ... That is 45.5 But he has to repeat this for all the suits therefore total of 45.5*4 = 182 times. Total steps for Bob = 52 + 182 = 234 Which is way lesser then that of Alice.
Its just that it takes less time to go through a suit than the whole deck.
Bob,obvious.I have used probability to solve this. Alice's prob to get ace of hearts in first time=1/52 then 2 of hearts = 1/51..likewise prob of her to solve this=1/52 * 1/51 ...=1/52! On the other hand, Bob's prob to sort each one of them=13/52 * 13/39 * 13/26 * 13/13=1/24. Then to solve this=(1/13 * 1/12 *..) 1/4 * 1/24 which is effectively greater than 1/52!. Hence Bob should be the first to complete.
People are forgetting that Bob goes through the entire deck as well. People are also forgetting that this is the computer science category. And so I was wondering, wouldn't a computer program sort the deck faster using Alice's method?
Problem Loading...
Note Loading...
Set Loading...
Bob will solve it indeed first. Case 1: Alice She goes through 52 rounds through the remaining set of cards to sort them out.
Case 2: Bob He goes through one round to sort the cards as per denomination (heart etc.) Then he goes through total of 13 rounds for each denomination but the difference from the case of Alice is that his size of set to search will go from 13,12,11 ..... ,1 in the similar manner four times. But in the case of Alice it goes from 52,51, ......, 13,12,11 ....,1 , she has to go through many more number of cards than Bob.