Assume a memory malfunction occurs halfway through sorting an array of N unsorte
ID: 3696096 • Letter: A
Question
Assume a memory malfunction occurs halfway through sorting an array of N unsorted integers that causes just one integer value in the array to be changed and then the sort completes. What can we say about the final array after the sorting completes? Your answers should say whether or not final array is sorted and, if unsorted, describe how the array is unsorted. For example:
--Bubble Sort: If a value in the sorted part changes to the largest value in the entire array then the final array is... not sorted and only that changed value will be out of order.
For each sort and circumstance specified below, finish the description of the final array after the sort completes. The sorts mentioned below are those covered in lecture (and readings) that sort the numbers in increasing order.
-Bubble Sort: If a value in the UNsorted part changes to the smallest value in the entire array then the final array is...
-Insertion Sort (linear): If a value in the UNsorted part changes to the smallest value in the entire array then the final array is...
-Insertion Sort (linear): If a value in the sorted part changes to the smallest value in the entire array then the final array is...
-Selection Sort (straight): If a value in the UNsorted part changes to the largest value in the entire array then the final array is...
-Selection Sort (straight): If a value in the sorted part changes to the largest value in the entire array then the final array is...
Explanation / Answer
Bubble Sort: Final array is unsorted because, In Bubble sort the neighbour elements are checked if one element has changed jsut for that part only sorted but, remaining part will remain the same.
Insertion Sort(linear): unsorted because as we can see in insertion sort we take one element and compare it with element before in it and put it in right position.
insertion sort(linear): sorted.
selection(straight):sorted because Straight selection is an O(n2) member of the class in which we repeatedly scan the remaining unsorted items in the list in linear time, find the largest (or smallest), and add it to the result.
selection(straight):unsorted because Straight selection is an O(n2) member of the class in which we repeatedly scan the remaining unsorted items in the list in linear time, find the largest (or smallest), and add it to the result. ,
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.