I have been implementing an algorithm into Java (Johnson and Trotter) and have found that my ArrayList containing all the numbers i am operating on disappears after a method is called, leading to no items being returned. I will explain the algorithm as best as i can below:
The algorithm i am trying to implement generates all possible shuffles of a collection of numbers by giving them all a direction and specifying any number bigger than the number it is pointing to as "mobile", every pass, the largest "mobile" number is swapped with the number it is pointing to and this generates a unique shuffle, this process continues until no numbers are "mobile", at which point, all combinations are found
The method which "vanishes" my ArrayList of numbers is the one which checks if a number is mobile or not, i have left a comment in the source code to where this method is called, which i have linked below.
Thank you for your help