I have a Linked List and I want to implement a function:
Random_Shuffle_List (struct node **Headptr) – which outputs a list such that every single node is randomly moved from its original position.
Please help me with an efficient algorithm to achieve this.
I would recommend the naïve approach:
This uses a relatively tiny bit of extra memory, of course, but I think it’s more “efficient” in terms of time to implement (and understand) and probably also run-time, than approaches working directly on the linked list.