🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Searching and Sorting in C: all 10 questions

Quiz: Searching and Sorting in C · Question 10 of 10

In insertion sort, why must the condition be j = 0 && a[j] key in that order?

In insertion sort, why must the condition be j >= 0 && a[j] > key in that order?

  1. A.The compiler requires constants first
  2. B.&& stops at the first false part, so a[-1] is never read when j becomes -1
  3. C.It makes the sort stable
  4. D.It does not matter
Answer & explanation

Correct answer: && stops at the first false part, so a[-1] is never read when j becomes -1

Short-circuit evaluation checks the bound first and protects the array access.

Can you get the rest right without peeking?

Take the timed Quiz: Searching and Sorting in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →