GATE DA 2026 Q49: Comparisons by bubble sort and insertion sort on a nearly sorted array
- Programming, Data Structures and Algorithms
- 2 marks
- MSQ
- No negative marking
Question
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?
Try it: multiple select: one or more correct options
Show answer and explanation
Answer: B, C, D (official GATE 2026 final answer key)
Concept used: Bubble sort compares adjacent pairs pass after pass; insertion sort compares each new element only until it finds its place.
First step: Insertion sort makes 1 + 1 + 1 + 2 = 5 comparisons and one swap; bubble sort needs at least a second pass to confirm the array is sorted.
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2026 DA question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Programming, Data Structures and Algorithms PYQs
- 2026 · Q15Expected-time recurrence for randomised-input quicksort
- 2026 · Q16Python mutable default argument output
- 2026 · Q25Binary tree from preorder and inorder traversals
- 2026 · Q31Worst-case comparisons in binary search of 1000 elements
- 2026 · Q39Number of calls made by a Fibonacci-like recursion
- 2026 · Q40Reachability in a graph and its reverse