Data Structures and Algorithms: Sorting includes Bubble Sort, Bubble Sort pseudocode, Bubble Sort performance, Insertion Sort, Insertion Sort pseudocode, Insertion Sort performance, Divide-and-Conquer, Merge Sort. | Sorting Data structures and Algorithms Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++ Goodrich, Tamassia and Mount (Wiley, 2004) Outline Bubble Sort Insertion Sort Merge Sort Quick Sort Sorting 2 Bubble Sort Algorithm 1. Compare each pair of adjacent elements from the beginning of an array and, if they are in reversed order, swap them. 2. If at least one swap has been done, repeat step 1. Reference: Sorting 3 1st pass 2nd pass 3rd pass 4th pass Bubble Sort pseudocode Algorithm bubbleSort(S, C) Input sequence S with n elements, comparator C Output sequence S sorted according to C do swapped ← false for each i in 1 to length(S) – 1 inclusive do: if S[i - 1] > S[i] according to C then swap(S[i - 1], S[i]) swapped ← true while .