Tony @ Mon Mar 31, 2014 2:18 pm wrote:
Conceptually they are the same thing -- you pick the two elements to swap, and then swap them.
With arrays, you have to figure out how to not overwrite a value (you've done that with temp variable).
With linked lists, you have to figure out how to end up with a valid structure after the swap operation. Sketching out a few diagrams would be very helpful, to get an idea of exactly what you need to change around.
ok... how do i select a random index in the linkedlist to be moved?