Insertion Sort Quiz

5 Questions

Settings
Please wait...
Data Structure Quizzes & Trivia

A quiz based on Insertion Sort


Questions and Answers
  • 1. 
    What are the correct intermediate steps of the following data set when it is being sorted with the Insertion sort? 15,20,10,18
    • A. 

      15,20,10,18 -- 10,15,20,18 -- 10,15,18,20 -- 10,15,18,20

    • B. 

      15,18,10,20 -- 10,18,15,20 -- 10,15,18,20 -- 10,15,18,20

    • C. 

      15,10,20,18 -- 15,10,18,20 -- 10,15,18,20

    • D. 

      10, 20,15,18 -- 10,15,20,18 -- 10,15,18,20

  • 2. 
    Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number. [1 3 4 8 9 || 5 2]
    • A. 

      2 comparisons, 3 swaps

    • B. 

      3 comparisons, 2 swaps

    • C. 

      4 comparisons, 3 swaps

    • D. 

      3 comparisons, 4 swaps

  • 3. 
    Consider the following lists of partially sorted numbers. The double bars represent the sort marker. How many comparisons and swaps are needed to sort the next number. [1 3 4 5 8 9 || 2]
    • A. 

      5 comparisons, 4 swaps

    • B. 

      4 comparisons, 5 swaps

    • C. 

      6 comparisons, 5 swaps

    • D. 

      5 comparisons, 6 swaps

  • 4. 
    If all the elements in an input array is equal for example {1,1,1,1,1,1}, What would be the running time of the Insertion Algorithm?
    • A. 

      O(2N)

    • B. 

      O(n^2)

    • C. 

      O(n)

    • D. 

      None of the above

  • 5. 
    What operation does the Insertion Sort use to move numbers from the unsorted section to the sorted section of the list? 
    • A. 

      Finding the minimum value

    • B. 

      Swapping

    • C. 

      Finding out an pivot value

    • D. 

      None of the above