CSE 214 Study Guide - Final Guide: Bubble Sort, Insertion Sort, Selection Sort

118 views2 pages

Document Summary

Basically array of items are sorted by separating the array into 2 parts (not literally. ) Basically finds the smallest item in the array and switches positions with the first item in the array. Then it continues and finds the next smallest element except this time it switches it with the 2nd element in the array. Right side of array is not sorted. Similar to selection sort with partitioning the array where sorted is on the left and unsorted is on the right. Selection sort takes the next number instead of finding the minimum and places it in the sorted area of the array based on its value. This means that the rest of the elements after it must be shifted over by 1. Everything after the 9 has to be shifted over by one in order to make room for placing the 9 in. Best: o(n) if the array is already sorted and nothing needs to be shifted.