- #1

- 251

- 0

working:

for the first past, maximum needed is n-1 swaps where n is the amount of the pieces of data

2nd - n-2

3rd - n-3

4th - n-4

5th - n-5

so generally it takes

(n-1) + (n-2) +... (n-(n-1))

is this correct? It works for six as the it will be a maximum of 15 swaps, also how can I generalise this?