@Sunny
Your technique of Inshuffle and Outshuffle are perfect. But how to translate
into the code without using extra space or say even constant space
On Tue, Oct 18, 2011 at 12:43 AM, Dan wrote:
> I have a hard copy of the book (years back, I implemented a fortran
> version of the algorithm
cheers..
clear explanation. thanks for the effort.. :)
so.. we swap 3 elements and.. run for one complete cycle of N/3 time in
this prob..
Anika has a recusion of N/3 depth.. may be.. a loop that runs N/3 time
should suffice.
:)
--
You received this message because you are subscribed to the
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)
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 weblin
Hi Anika,
Can you comment on the complexity of the algorithm?
It appears to be like an O(n^2).
By the way, we are asked for a inplace sort, and this recursive call stores
the 3 element(a,b,c) in each level.
So, i iterations, and starting value of i is n/3.. so this takes an
additional O(n) tim
initial call to this function is arrange(arr,n/3,n/3) where n is actually
3*n as per the question , like n=30 for a1,...,a10,b1,...,b10,c1,c10
The idea used here is that for some i-1 ranging from 1 to 9 for above
example, i-1 goes to 3*(i-1), n+i-1 to 3*(i-1) +1, and 2*n+i-1 to
3*(i-1)+2.. rec
i have already mentioned the source
it is famous shuffling algorithm. u can seach some papers on In-Shuffle
and Out-Shuffle
the original question in the shuffling is like how many times we need to
shuffle the cards after which they will return back to initial sequence.
On Sat, Oct 15, 2011 at
@Sunny ..Superb Algo ..but can you share some link where we can read abt it
:)..especially where the info abt the equation u used is given
Thanks in Advance
On Sat, Oct 15, 2011 at 12:37 PM, Kunal Patil wrote:
> @Sunny: Thanks for the info !! That's gr8..& your logic also seems to be
> workin
@Sunny: Thanks for the info !! That's gr8..& your logic also seems to be
working perfectly fine..
On Sat, Oct 15, 2011 at 12:16 PM, shady wrote:
> u can always post the code.,... but before posting code, you must state
> your algorithm
> else code becomes useless for other users
>
> On Sat, Oc
u can always post the code.,... but before posting code, you must state your
algorithm
else code becomes useless for other users
On Sat, Oct 15, 2011 at 1:10 AM, Anika Jain wrote:
> i have the code solution to this.. if m allowed to post it here then i can
> i post it. m i allowed to post code
@Anika , You Already Have Permission to Post All Algorithms Realted
Questions/Queries
Thanks
Shashank
CSE,BIT Mesra
--
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
@Dan ..can you post the algo here or link to the book??
@Anika ...yes please post the code here..but please explain a bit about
underlying algo ...(algo is more important than actual code )
On Sat, Oct 15, 2011 at 1:54 AM, Dan wrote:
> On Oct 13, 7:52 pm, "shiva@Algo" wrote:
> > Convert an ar
Is there a pattern in the indices of the numbers we are swapping. some
formula which may tell the next two indices to swap.
Thanks,
- Ravindra
On Fri, Oct 14, 2011 at 9:40 PM, gaurav yadav wrote:
> @shiva...keep swapping the underline elements
>
> a1*a2*a3a4a5*b1*b2b3b4b5c1c2c3c4c5
> a1b1*a3*a4
i have the code solution to this.. if m allowed to post it here then i can i
post it. m i allowed to post code here?
On Fri, Oct 14, 2011 at 9:40 PM, gaurav yadav wrote:
> @shiva...keep swapping the underline elements
>
> a1*a2*a3a4a5*b1*b2b3b4b5c1c2c3c4c5
> a1b1*a3*a4a5a2b2b3b4b5*c1*c2c3c4c5
>
@shiva...keep swapping the underline elements
a1*a2*a3a4a5*b1*b2b3b4b5c1c2c3c4c5
a1b1*a3*a4a5a2b2b3b4b5*c1*c2c3c4c5
a1b1c1*a4*a5*a2*b2b3b4b5a3c2c3c4c5
a1b1c1a2*a5*a4*b2*b3b4b5a3c2c3c4c5
a1b1c1a2b2*a4*a5b3b4b5a3*c2*c3c4c5
a1b1c1a2b2c2*a5*b3b4b5*a3*a4c3c4c5
a1b1c1a2b2c2a3b3*b4*b5a5a4*c3*c4c5
a1b1c1a
What should be the output in this case : a1a2a3a4b1b2b3b4c1c2c3c4 ??
--
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+uns
this problem is like Card shuffling problem(search for In-shuffle)
i think solution is
if indexing is zero based
each i will go to -> k*i % (N-1)
k = 3 and N = 3*n -1
n = no of cards in one pile Or No of a's
On Fri, Oct 14, 2011 at 7:52 PM, shiva@Algo wrote:
> @Gaurav how will u do for
>
Its Out Shuffle not In shuffle, although both are similar and you can read
both
On Fri, Oct 14, 2011 at 8:26 PM, sunny agrawal wrote:
> this problem is like Card shuffling problem(search for In-shuffle)
> i think solution is
> if indexing is zero based
> each i will go to -> k*i % (N-1)
>
@Gaurav how will u do for
a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5
On Fri, Oct 14, 2011 at 6:49 AM, gaurav yadav wrote:
> consider following example...
> suppose initailly we have a1a2a3b1b2b3c1c2c3
>
> then do the following->
> a1a2a3 b1b2b3 c1c2c3 (look for b1 in the remaining array and swap with
>
consider following example...
suppose initailly we have a1a2a3b1b2b3c1c2c3
then do the following->
a1a2a3 b1b2b3 c1c2c3 (look for b1 in the remaining array and swap with
a2 , so in this case swap(a2,b1) )
a1b1a3 a2b2b3 c1c2c3 (similarly swap(a3,c1) )
a1b1c1 a2b2b3 a3c2c3swap(b3,
@Utkarsh As efficient as possible..
On Fri, Oct 14, 2011 at 6:25 AM, UTKARSH SRIVASTAV
wrote:
>
>
> @siddharth what is the complexity?
>
> --
> *UTKARSH SRIVASTAV
> CSE-3
> B-Tech 3rd Year
> @MNNIT ALLAHABAD*
>
>
> --
> You received this message because you are subscribed to the Google Group
@siddharth what is the complexity?
--
*UTKARSH SRIVASTAV
CSE-3
B-Tech 3rd Year
@MNNIT ALLAHABAD*
--
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
22 matches
Mail list logo