Question

In: Computer Science

Given the following data set N =9 12 3 78 89 22 31 5 20 14...

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

Solutions

Expert Solution

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.


Related Solutions

Using C ++, Given the following data set N =9 12 3 78 89 22 31...
Using C ++, 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
For the following data set, 5, 9, 12, 15, 19, 21, 22, 22, 24, 26, 27,...
For the following data set, 5, 9, 12, 15, 19, 21, 22, 22, 24, 26, 27, 27, 31, 33, 33, 34, 37, 38, 60, 70 a) Find the quartiles Q1 Q2 Q3 b) Find the five number summary c) Find the interquartile range (IQR) IQR = d) Find the lower limit LL = e) Find the upper limit UL = f) Identify the potential outliers (Separate each outlier with a comma. Write NPO if there is no potential outlier) The...
5. Given the data set A = {9, 5, 16, 4, 32, 8, 12, 9, 11,...
5. Given the data set A = {9, 5, 16, 4, 32, 8, 12, 9, 11, 15, 5, 9, 18, 10}, which is the data of an entire population of subjects: a. Calculate the arithmetic mean (5 pts) b. Find the median (5 pts) c. Find the mode (5 pts) d. Calculate the range (5 pts) e. Calculate the interquartile range (5 pts) f. Calculate the mean deviation (5 pts) g. Calculate the variance (5 pts) h. Calculate the standard...
You have been given the following set of keys 12, 45, 1, 9, 67, 230, 78,...
You have been given the following set of keys 12, 45, 1, 9, 67, 230, 78, 64, 450, 436, 123, 6, 12, 90 Use insertion to sort the elements in ascending and descending order ( show the steps)     [5 Marks] Using heaps, show how the keys can be sorted in ascending and descending order ( show the steps)      [5 Marks] Using Big O, derive the space and time complexity of insertion sort and heap sort algorithms above
The following set of data is from a sample of n= 7: 12 7 4 9...
The following set of data is from a sample of n= 7: 12 7 4 9 0 7 20 A) compute the mean, median, and mode. B) compute the range, variance, standard deviation, and coefficient of variation C) compute the Z score of 0 and 20. Are there any outliers? D) compute the first quartile, the third quartile, and the interquartile range
Given the following data: x 2 8 5 12 9 y 6 11 7 14 10...
Given the following data: x 2 8 5 12 9 y 6 11 7 14 10 a) draw/graph a scatter plot. b) by hand, find the correlation coefficient r. c) by hand, find b0 and b1. d) write the regression equation.
Given the data set below 25 52 67 23 78 89 57 90 32 77 45...
Given the data set below 25 52 67 23 78 89 57 90 32 77 45 48 62 54 94 69 46 79 40 33 21 57 84 54 23 34 68 63 61 76 87 78 39 50 70 60 32 65 73 45 28 82 66 79 71 80 46 66 24 90 A)What is the probability of an impossible even? B) What is the probability of a certain event? C) find the approximate mean using the Frequency...
4. [22 pts] For the function ?(?) = 2?5 − 9?4 + 12?3 − 12?2 +...
4. [22 pts] For the function ?(?) = 2?5 − 9?4 + 12?3 − 12?2 + 10? − 3 answer the following: a. [2 pts] Determine whether the function represents a polynomial. Justify your answer. b. [4 pts] Determine whether the function satisfies the Intermediate Value Theorem on the interval [0, 5]. Justify your answer. c. [2 pts] Determine the number (quantity) of complex zeros that the function has, provided the each zero is counted by its multiplicity. d. [4...
Using the following data set: 10, 5, 2, 7, 20, 3, 13, 15, 8, 9 Apply...
Using the following data set: 10, 5, 2, 7, 20, 3, 13, 15, 8, 9 Apply the Merge sort algorithm. [Show to sorting process of the first half only] Apply the Quick sort algorithm [Show the first partitioning implementation]
The following is a set of data from a sample of n equals 5n=5. 5   −4   −5   5   9     Please...
The following is a set of data from a sample of n equals 5n=5. 5   −4   −5   5   9     Please use a statistical application​ (data Analysis Toolpak for​ Windows, StatPlus for Mac​ Excel, or​ StatCrunch) to compute the descriptive statistics in a. and b. ​(If you​ don't know what​ I'm talking​ about, go to Module 1 Content​ -- Read/View​ -- Tutorials.) a. Compute the​ mean, median, and mode. b. Compute the​ range, sample​ variance, and sample standard deviation. c. Compute the coefficient of variation....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT