Skills101
← All practice quizzes

Quiz: Sorting Basics

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

The three simple sorting algorithms every interview expects you to know, traced step by step, with Python and Java code, their complexity and when insertion sort is actually the right choice.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    a = [4, 3, 2, 1]
    for i in range(1, len(a)):
        key, k = a[i], i - 1
        while k >= 0 and a[k] > key:
            a[k + 1] = a[k]
            k -= 1
        a[k + 1] = key
        if i == 2:
            print(a)
    
  2. Question 2

    Which simple sort is fastest on an array that is already almost sorted?

  3. Question 3

    Which of these sorts is NOT stable in its usual form?

  4. Question 4

    What is the best-case time of bubble sort with the "stop if no swap" check?

  5. Question 5

    You must sort an array where every write to memory is very costly. Which simple sort writes the least?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?24 students have taken today’s challengeTake today’s challenge →