Insertion Sort Quiz Questions And Answers

Reviewed by Godwin Iheuwa
Godwin Iheuwa, MS, Computer Science |
Computer Expert
Review Board Member
Godwin is a proficient Database Administrator currently employed at MTN Nigeria. He holds as MS in Computer Science from the University of Bedfordshire, where he specialized in Agile Methodologies and Database Administration. He also earned a Bachelor's degree in Computer Science from the University of Port Harcourt. With expertise in SQL Server Integration Services (SSIS) and SQL Server Management Studio, Godwin's knowledge and experience enhance the authority of our quizzes, ensuring accuracy and relevance in the realm of computer science.
, MS, Computer Science
Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By RosyU
R
RosyU
Community Contributor
Quizzes Created: 6 | Total Attempts: 41,396
Questions: 10 | Attempts: 11,086

SettingsSettingsSettings
Insertion Sort Quiz Questions And Answers - Quiz

Do you know what an insertion sort is? Here's an interesting Insertion Sort Quiz to test your knowledge. It is a simple sorting algorithm that builds the final sorted array one item at a time. This algorithm works similarly to the sorting of playing cards in hands. If you think you have a good understanding of insertion sort, then you must try this quiz and see if you can pass this test or not. If you score more than 70%, it means that you've passed this quiz. So, get ready to start the quiz!


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

    Correct Answer
    A. 15,20,10,18 -- 10,15,20,18 -- 10,15,18,20 -- 10,15,18,20
    Explanation
    The given answer shows the correct intermediate steps of the data set being sorted with the Insertion sort algorithm. The initial step is the given data set itself. In the first step, the algorithm compares 20 with 15 and swaps them to get 10,15,20,18. In the second step, the algorithm compares 10 with 15 and swaps them to get 10,15,18,20. In the third step, the algorithm compares 18 with 20 and leaves them as they are to get 10,15,18,20. The final step is the same as the third step since the data set is already sorted.

    Rate this question:

  • 2. 

    What will be the number of passes to sort the elements using insertion sort? 14, 12,16, 6, 3, 10

    • A.

      7

    • B.

      8

    • C.

      1

    • D.

      5

    Correct Answer
    D. 5
    Explanation
    To determine the number of passes needed to sort the elements using insertion sort, we first need to understand the insertion sort algorithm.
    In each pass of insertion sort, the algorithm selects an unsorted element and inserts it into its correct position in the sorted portion of the array.
    Given the elements: 14, 12, 16, 6, 3, 10
    Here's the process:
    Pass 1: 12, 14, 16, 6, 3, 10 Pass 2: 12, 14, 16, 6, 3, 10 Pass 3: 6, 12, 14, 16, 3, 10 Pass 4: 3, 6, 12, 14, 16, 10 Pass 5: 3, 6, 10, 12, 14, 16
    It took 5 passes to sort the elements using insertion sort.
    So, the correct answer is 5.

    Rate this question:

  • 3. 

    Which of the following options contain the correct feature of an insertion sort algorithm?

    • A.

      Dependable

    • B.

      Stable, adaptive

    • C.

      Anti-stable

    • D.

      None of the above

    Correct Answer
    B. Stable, adaptive
    Explanation
    The correct answer is "stable, adaptive." In an insertion sort algorithm, stability refers to the preservation of the relative order of equal elements in the sorted array. Adaptive means that the algorithm's efficiency can be improved if the input is already partially sorted. Both of these features are important in an insertion sort algorithm. The other options, "dependable" and "anti-stable," do not accurately describe the features of an insertion sort algorithm.

    Rate this question:

  • 4. 

    State true or false. Binary search can be used in an insertion sort algorithm to reduce the number of comparisons.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    Binary search can be used in an insertion sort algorithm to reduce the number of comparisons. This is because binary search allows for efficiently finding the correct position to insert an element in a sorted array. By using binary search, the algorithm can quickly locate the correct position and minimize the number of comparisons needed to find the correct position for each element being inserted. This ultimately leads to a more efficient insertion sort algorithm.

    Rate this question:

  • 5. 

    Which of these sorting algorithms is the fastest for sorting small arrays?

    • A.

      Insertion sort

    • B.

      Quick sort

    Correct Answer
    A. Insertion sort
    Explanation
    Insertion sort is the fastest sorting algorithm for sorting small arrays because it has a time complexity of O(n^2), which means it performs well for small input sizes. It works by iteratively inserting each element into its correct position in the sorted part of the array. This algorithm has a low overhead and performs efficiently when the array is already partially sorted or contains mostly sorted elements. On the other hand, Quick sort has an average time complexity of O(nlogn) but can have a worst-case time complexity of O(n^2), making it less efficient for small arrays.

    Rate this question:

  • 6. 

    Which of these is not a stable sorting algorithm in its typical implementation?

    • A.

      Merge sort

    • B.

      Quick sort

    • C.

      Insertion sort

    • D.

      None of the above

    Correct Answer
    B. Quick sort
    Explanation
    Quick sort is not a stable sorting algorithm in its typical implementation. Stability refers to the preservation of the relative order of equal elements in the sorted output. Quick sort involves partitioning the array based on a pivot element, and the order of equal elements may change during this process. Therefore, Quick sort does not guarantee the stability of the sorting algorithm. On the other hand, Merge sort and Insertion sort are stable sorting algorithms as they maintain the relative order of equal elements. Hence, the correct answer is Quick sort.

    Rate this question:

  • 7. 

    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

    Correct Answer
    B. 3 comparisons, 2 swaps
    Explanation
    The given list is partially sorted, with the sort marker indicating the boundary between the sorted and unsorted portions. To sort the next number (5), we need to compare it with each number in the sorted portion until we find its correct position. In this case, we need to make 3 comparisons (with 1, 3, and 4) before finding the correct position for 5. Additionally, we need to make 2 swaps to move the numbers 5 and 2 to their correct positions (5 before 8 and 2 before 5). Therefore, the correct answer is 3 comparisons, 2 swaps.

    Rate this question:

  • 8. 

    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

    Correct Answer
    C. 6 comparisons, 5 swaps
    Explanation
    To sort the next number, we need to compare it with each number in the partially sorted list until we find its correct position. In this case, the number 2 needs to be compared with 1, 3, 4, 5, 8, and 9, which makes a total of 6 comparisons. Additionally, since the number 2 needs to be placed before the numbers 3, 4, 5, 8, and 9, we need to perform 5 swaps to sort it correctly. Therefore, the answer is 6 comparisons and 5 swaps.

    Rate this question:

  • 9. 

    If all the elements in an input array are 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

    Correct Answer
    C. O(n)
    Explanation
    The running time of the Insertion Algorithm would be O(n) in this case because even though all the elements in the input array are equal, the algorithm still needs to iterate through each element in order to perform the necessary comparisons and insertions. The number of iterations is directly proportional to the size of the input array, hence the running time is linear.

    Rate this question:

  • 10. 

    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

    Correct Answer
    B. Swapping
    Explanation
    Insertion Sort uses the operation of swapping to move numbers from the unsorted section to the sorted section of the list. In this sorting algorithm, each element is compared with the elements before it in the sorted section, and if it is smaller, it is swapped with the element before it until it reaches its correct position. This process continues until all elements are in their correct sorted positions. Therefore, the correct answer is swapping.

    Rate this question:

Godwin Iheuwa |MS, Computer Science |
Computer Expert
Godwin is a proficient Database Administrator currently employed at MTN Nigeria. He holds as MS in Computer Science from the University of Bedfordshire, where he specialized in Agile Methodologies and Database Administration. He also earned a Bachelor's degree in Computer Science from the University of Port Harcourt. With expertise in SQL Server Integration Services (SSIS) and SQL Server Management Studio, Godwin's knowledge and experience enhance the authority of our quizzes, ensuring accuracy and relevance in the realm of computer science.

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 14, 2024
    Quiz Edited by
    ProProfs Editorial Team

    Expert Reviewed by
    Godwin Iheuwa
  • Dec 25, 2011
    Quiz Created by
    RosyU
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.