Link Details

Link 83897 thumbnail
User 292570 avatar

By syam1224
via linkmingle.com
Published: May 31 2008 / 08:03

Card Shuffling is a general interview question for many companies including Microsoft,Google and Amazon.This link has a code snippet which will shuffle a deck of cards using Knuth Shuffle.
  • 6
  • 3
  • 9132
  • 666

Comments

Add your comment
User 228478 avatar

wheazel replied ago:

-2 votes Vote down Vote up Reply

Collections.shuffle() nor the suggested algoritme is very good.

Real card decks are shuffled by hand, meaning you take a part of the deck and place it on top.
Random shuffles will impact game, since the cards are too random...

User 292570 avatar

syam1224 replied ago:

0 votes Vote down Vote up Reply

Hand Shuffling is not good if not done scientifically.
A normal poker shuffle involve multiple standard shuffles.
The Knth algorithm is perfect if we could find a random number between 0 and N, which is not theoretically possible using computers. But to almost all practical purposes this should suffice

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (6)



Voters Against This Link (3)



Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java