GATE Assistant

Past questions › Data Science and Artificial Intelligence › GATE 2026

GATE 2026 · DA · MSQ · 2 marks · Programming, Data Structures and Algorithms › Basic Sorting

GATE 2026 Data Science and Artificial Intelligence question: Consider the problem of sorting the given array in ascending order: P = [1, 2, 3, 5, 4]…

Consider the problem of sorting the given array in ascending order:

P = [1, 2, 3, 5, 4]

Consider two sorting algorithms Bubble Sort (BS) and Insertion Sort (IS). Let N1 be the total number of comparisons done by BS on the elements of P and N2 be the total number of comparisons done by IS on the elements of P.

Which of the following options is/are correct?

  1. (A)

    N1 = 10, N2 = 4

  2. (B)

    N1 > N2

  3. (C)

    IS on P will perform only one swap

  4. (D)

    Both BS and IS on P will make at least one unnecessary comparison (i.e., comparing elements that are already in correct order)

Show answer

This question is in an all-India live mock that is open now. Its answer appears here when the mock closes.

Practise this question with exam-style marking