Updated 3 years ago
Sorting Algorithms
arr = [2,7,3,9,1,6]
arr[1],arr[1+1] = arr[1+1],arr[1]
arr
[2, 3, 7, 9, 1, 6]
arr1 = [2,3,7,9,1,6]
arr2 = [9,8,7,6,5,4]
Bubble Sort:
Compare and swap:
arr = [2,7,3,9,1,6]
arr[1],arr[1+1] = arr[1+1],arr[1]
arr
[2, 3, 7, 9, 1, 6]
arr1 = [2,3,7,9,1,6]
arr2 = [9,8,7,6,5,4]
Compare and swap: