Swapping Elements in an Array

 

array 2 5 12 9 8 18 15
           
indices 0 1 2 3 4 5 6