Question: EXERCISE 4: SAMPLE OR QUADRATIC SORTING ALGORITHMS Given the fdhowing BubbleSort() function, answer the following questions. 1 2 3 // Program 5.13 void BubbleSort (dataType

 EXERCISE 4: SAMPLE OR QUADRATIC SORTING ALGORITHMS Given the fdhowing BubbleSort()

function, answer the following questions. 1 2 3 // Program 5.13 void

BubbleSort (dataType data[], int listSize) { int pass, tempValue; for (pass =

EXERCISE 4: SAMPLE OR QUADRATIC SORTING ALGORITHMS Given the fdhowing BubbleSort() function, answer the following questions. 1 2 3 // Program 5.13 void BubbleSort (dataType data[], int listSize) { int pass, tempValue; for (pass = 1; pass data [x+1]) { tempValue = data[x] ; data[x] = data[x+1]; data (x+1] = tempValue; } } } 9 10 11 12 6 What would be the sequence order of list produced using the above BubbleSort() function? Ascending or descending order? b. Based on the BubbleSort() function given above, show step by step tracing the implementation of the sorting algorithm in sorting Array L and M as below. Show the steps by completing the following diagrams. [0] [1] [2] [3] 2 4 8 24 [0] [1] [2] [3] 24 8 4 2 Array L Array M Array Z pass pass pass 8 122 4 2 101 Array M pass= pass= pass= 2 4 8 10) 24 Given the following Sort() function, show step by step tracing the implementation of the sorting algorithm in sorting the same array L and M. 2 17 Program 5.14 void Sort (dataType data[]) { dataType item; int pass, index; for (pass = 1; pass 0) && (data[index -1] > item)) data[index] = data[index-1); index--; ) data[index] item; 12 Array L passe passa passa 133 24 12] 8 [1] 10 2 131 Array M pass= pass= Pass= [3] 2. [2] 4 [1] 8. [0] 24 d. Referring to your tracing answers for array L in both sorting functions (BubbleSort() and Sort()), identify the number of comparisons in each pass to sort the data for both sorting functions. Discuss the algorithm complexity of the two sorting functions based on the data in array L. Sorting Array L BubbleSort() Sort() Number of pass Number of comparisons e. Referring to your tracing answers for array M in both sorting functions Bubblesort () and Sort()), identify the number of comparisons in each pass . to sort the data for both sorting functions. Discuss the algorithm complexity of the two sorting functions based on the data in array M. Sorting Array M BubbleSort() Sort() Number of pass Number of comparisons

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!