← 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?
- A.The compiler requires constants first
- B.&& stops at the first false part, so a[-1] is never read when j becomes -1
- C.It makes the sort stable
- 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 →