In: Computer Science
Given the following data set N =9
12 3 78 89 22 31 5 20 14
a ) sort the data using: Insertion and Selection sorts
Determine thee number of comparisons and the number of moved for every sort.
b) Sort the data using Heap and bubble sort, show all steps
a) In insertion sort key element is compared with the predecessor, if it is smaller compared with all predecessors.Larger elements will make a room by shift.
In selection sort, minimum element will be scanned out and put in the first position.The same process continues until the list becomes sorted.
All the steps have shown in detail in the following images.
(b) Heap sort and bubble sort steps have also shown in detail in the following images.