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.