Question

In: Computer Science

1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}. What is...

1a)Giving an array of integers A[1:8] ={5, 1, 3, 2, 7, 6, 8, 4}.

What is the running time of the insertion sort if both A[1..n/2] and A[n/2+1,n] are also sorted. Justify your answer.

2-illustrate the operation of RADIX-SORT on the following list of English words: COW, DOG, SEA, RUG, ROW, MOB, BOX, TAB, BAR, EAR, TAR, DIG, TEA, NOW, FOX.

3-Use counting sort, sort the following numbers: 4, 2, 5, 4, 2, 3, 0, 2, 4, 3

Solutions

Expert Solution

Q.1 If the arrays are sorted in ascendign order, the best case occurs which is O(n), while if the array is sorted in descending order, worst case occurs which result in complexity of O(n2). So according to array given, if 8 element are there and both half arrays are sorted ascending then running time complexity will be n i.e 8. But if the arrays are sorted in descending order then complexity will be n2 result in 64.

Q.2

Bucketing on char 0 from the right
[65] SEA -> TEA
[66] MOB -> TAB
[71] DOG -> RUG -> DIG
[82] BAR -> EAR -> TAR
[87] COW -> ROW -> NOW
[88] BOX -> FOX

SEA -> TEA -> MOB -> TAB -> DOG -> RUG -> DIG -> BAR -> EAR -> TAR -> COW -> ROW -> NOW -> BOX -> FOX
Bucketing on char 1 from the right
[65] TAB -> BAR -> EAR -> TAR
[69] SEA -> TEA
[73] DIG
[79] MOB -> DOG -> COW -> ROW -> NOW -> BOX -> FOX
[85] RUG

TAB -> BAR -> EAR -> TAR -> SEA -> TEA -> DIG -> MOB -> DOG -> COW -> ROW -> NOW -> BOX -> FOX -> RUG
Bucketing on char 2 from the right
[66] BAR -> BOX
[67] COW
[68] DIG -> DOG
[69] EAR
[70] FOX
[77] MOB
[78] NOW
[82] ROW -> RUG
[83] SEA
[84] TAB -> TAR -> TEA

BAR -> BOX -> COW -> DIG -> DOG -> EAR -> FOX -> MOB -> NOW -> ROW -> RUG -> SEA -> TAB -> TAR -> TEA


BAR
BOX
COW
DIG
DOG
EAR
FOX
MOB
NOW
ROW
RUG
SEA
TAB
TAR
TEA

Q.3

I hope it helps.
Thank you


Related Solutions

Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5...
Matrix A2= [1 2 3; 4 5 6; 7 8 9; 3 2 4; 6 5 4; 9 8 7] Note: TA2 is defined to be a linear transformation that maps any vector x to A2* x. That is TA2 = A2*x. Also the range of the Linear transformation represented by A2 is the same as the column space of A2. l) Find a basis for the null(TA2). m) Find nullity of A2, TA2 and A2tA2. n) Find rank(A2), rank(A2t),...
Ex 1. Show the contents of the array of integers 5 7 4 9 8 5...
Ex 1. Show the contents of the array of integers 5 7 4 9 8 5 6 3 each time a selection sort changes it while sorting the array into ascending order. Initial array:   5 7 4 9 8 5 6 3 ANSWER (Hint there are 8 lines, Show Array after each selection and swap):
Given the unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] P E R...
Given the unordered array: [0] [1] [2] [3] [4] [5] [6] [7] [8] P E R Y I H J L S Suppose this array were being sorted using the quick sort algorithm from the course content, into ASCENDING order, with the left-most item as the pivot value. List the letters in the resulting array, in order AFTER the FIRST PARTITIONING. [0] [1] [2] [3] [4] [5] [6] [7] [8]
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7...
x 2 8 5 9 4 3 9 6 7 8 y 3 6 5 7 9 7 4 6 9 9 -5.48x + 0.17 5.48x + 0.17 -0.17x + 5.48 0.17x + 5.48
trace by using quicksort on the array : 4 6 5 3 2 7 1 using...
trace by using quicksort on the array : 4 6 5 3 2 7 1 using 7 as the pivot
ID X Y 1 2 3 2 3 6 3 4 6 4 5 7 5...
ID X Y 1 2 3 2 3 6 3 4 6 4 5 7 5 8 7 6 5 7 7 6 7 8 8 8 9 7 8 10 12 11 Test the significance of the correlation coefficient. Then use math test scores (X) to predict physics test scores (Y).  Do the following: Create a scatterplot of X and Y. Write the regression equation and interpret the regression coefficients (i.e., intercept and slope). Predict the physics score for each....
[4 5 5 2 4 4 6 3 3 7 5 3 6 3 4 4...
[4 5 5 2 4 4 6 3 3 7 5 3 6 3 4 4 6 5 4 5 3 7 5 5 4 2 6 5 6 6] This is my dataset Find mean, median, mode, variance, standard deviation, coefficient of variation, range, 70th percentile, 3rdquartile of the data and skewness and define what each of these statistics measure. For example, mean is a measure of the central tendency, what about the rest? Use Chebyshev’s rule to find...
[4 5 5 2 4 4 6 3 3 7 5 3 6 3 4 4...
[4 5 5 2 4 4 6 3 3 7 5 3 6 3 4 4 6 5 4 5 3 7 5 5 4 2 6 5 6 6] This is my dataset Split the dataset in two equal parts. You have 30 datavalues. If you split the data in two equal parts each part will contain 15 data values.  Call the first part Y and second part X.Draw scatter plot of the 2 datasets, X being on the horizontal...
tens Units 1 5 2 3 4 8 5 2 5 6 9 6 1 3...
tens Units 1 5 2 3 4 8 5 2 5 6 9 6 1 3 5 4 7 9 7 0 0 4 5 6 9 9 8 1 3 5 6 8 9 9 0 1 2 3 5 9 The table represent a random sample of 31 test scores taken from a large lecture class. Find the following [round to 2 decimal points X. XX] a) [2 pts] Find the 5 number summary [L, Q1, Q2, Q3,...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5...
3 6 4 8 1 10 2 9 11 12 15 22 3 6 7 5 8 1 12 14 Each column represents a different treatment given to sick rats. Each cell is a different rat. Use statistical analysis and use post hoc testing using contrasts to find the best treatment. Treatment 1: vitamins Treatment 2: prescription pills Treatment 3: brain surgery Treatment 4: shock therapy Treatment 5: dietary changes
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT