Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SelectionSort {
- public SelectionSort(int[] a)
- {
- //this.a = a;
- //shallow copy
- //OR THIS?
- //deep copy
- this.a = new int[a.length];
- for(int i = 0; i < a.length; i++)
- this.a[i] = a[i];
- }
- public int sort()
- {
- for (int i = 0; i < a.length; i++)
- {
- int min = ArrayUtil.minimumPosition(i, a);
- ArrayUtil.swap(min, i, a);
- swaps++;
- }
- return swaps;
- }
- public int[] getArray()
- {
- return a;
- }
- public int getSwaps()
- {
- return swaps;
- }
- private int swaps;
- private int[] a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement