you are here->home->Class 12->Insertion Sort
Insertion Sort
 1) Consider the following list and what is the status of the array after the fourth pass when we use the insertion sort? List elements are: 20, 16, 12, 8, 4, 1 16, 20, 12, 8, 4, 1 4, 8, 12, 16, 20, 1 12, 16, 20, 8, 4, 1 8, 12, 16, 20, 4, 1

 2) What is the number of iterations needed for Insertion Sort to arrange a list of 8 elements when they are initially arranged in reverse order? 8 6 9 7

 3) If the list A contains the items 10, 4, 7, 23, 67, 12 and 5 in that order, what will be the resultant list A after third pass of insertion sort? 4, 7, 10, 23, 67, 12, 5 10, 7, 4, 67, 23, 12, 5 4, 5, 7, 67, 10, 12, 23 67, 12, 10, 5, 4, 7, 23

 4) As part of the maintenance work, you are entrusted with the work of rearranging the library books in a shelf in proper order, at the end of each day. The ideal choice will be ____. Insertion sort Bubble sort Selection sort Quick sort

 5) Which algorithm out of the following options uses the least number of comparisons (among the list elements) to sort below array in ascending order? List = [22, 33, 44, 67, 71, 73, 88, 92] Quick sort Insertion sort Selection sort Bubble sort

 6) Which of the following is TRUE of the time complexity of the insertion sort algorithm to sort a list of ‘n’ integers? O(n logn) O(n^3) O(n) O(n^2)

 7) “Insertion sort works better when array is almost sorted“ True False

 8) What are the basic loops required to perform an insertion sort? for and if if else do while for and while

 9) What will be the output of the following code part? def insertion Sort(arr): if (n := len(arr)) <= 1: return for i in range(1, n): key = arr[i] j = i - 1 while j <= 0 and key < arr[j] arr[j + 1] = arr[j] j = 1 arr[j + 1] = key arr = [12, 11, 13, 5, 6] insertionSort(arr) print(arr) [0, 0, 0, 0, 0] [5, 6, 11, 12, 13] [5, 6, 11, 13, 12] [1, 0, 1, 0, 1]

 10) Fill in the blanks with suitable choice. insertionSort(array) mark first element as sorted for each unsorted element X 'extract' the element X for j <- lastSortedIndex down to 0 if current element j > X move sorted element to the right by break loop and insert X here end insertionSort n 2 1 0