In/Out Shuffle are two shuffling algorithms used for shuffling cards consider a pack of cards (so N = 52) and let cards are numbered from 1, 52
*In Shuffle *: cards are divided into 2 piles (k = 2) (1,2,3.....26) (27,28,.......52) afer one shuffle operation cards will be like (27,1)(28,2) ..........(52,26) and it can be found that the card at position i(0 indexed) has moved to its new position given by formula *i <- 2*i %(N+1) N = 52 *for k piles answer will be simply *k*i % (N+1) N = 52* *Out Shuffle *: cards are divided into 2 piles (k = 2) (1,2,3.....26) (27,28,.......52) afer one shuffle operation cards will be like (1, 27)(2,28) ..........(26,52) and it can be found that the card at position i(0 indexed) has moved to its new position given by formula *i <- 2*i %(N-1) N = 52 *for k piles answer will be simply *k*i % (N-1) N = 52 *now relating this to the Question in this thread k = 3 N = total no of elements in the array shuffle is Out shuffle now for writing program i think it can be done in O(2*n) ...will try to code soon :) On Sun, Oct 16, 2011 at 3:16 AM, sravanreddy001 <sravanreddy...@gmail.com>wrote: > Anika, > Your algorithm appears to take O(n^2) time and also O(n) space in recursion > stack space, storing the 3 elements in recursion level. > > The direct shifting of elements to the right will take O(n2) time and O(1) > space. > > Please comment if my assumptions are incorrect. > > Can anyone provide weblink for IN?OUT shuffle card shuffling prob related > to this scenario. > and Memory efficient rearragnement of array elements. > > Thanks, > sravanreddy001 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/RdrlNoIGpBEJ. > > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Sunny Aggrawal B.Tech. V year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.