I'm working with doubly linked lists in c++, I have written my classes and constructors. I need help with a randomizing method, any guidance or sample code would be appreciated, I'm pretty lost. For the method: void DLL::Random(); I want to basically shuffle/randomize my list. My list is a list of strings (names) if that's important to know. I'm mainly struggling with how to use pointers to prev and next to apply to each node and then move them throughout the list. Thanks in advanced!
Randomizing a doubly linked is not feasible.
Let me explain to you why.
We both know, DLL is a list of nodes with links to each other in a
sequence. To break or modify that sequence, we need to keep track
of the pointers, both prev, and next. Even, if a single pointer is
lost, the data will be lost.
Randomizing is basically, taking up a node and placing it anywhere in the list. So, to write such a code, you need to hard code it. Hard code in the sense, that taking up any node randomly, then finding a place, finding prev, and next to that place and linking it. Hence, it is quite manual process due to which it is infeasible.
Get Answers For Free
Most questions answered within 1 hours.