Skills101
← All practice quizzes

Quiz: Merge Sort and Quick Sort

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

How merge sort and quick sort reach O(n log n), traced with diagrams; the merge step, Lomuto partition, the worst case of quick sort and how to avoid it, with Python and Java code.

Log in to take the quiz

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

  1. Question 1

    What does this print?

    def merge(l, r):
        out, i, k = [], 0, 0
        while i < len(l) and k < len(r):
            if l[i] <= r[k]:
                out.append(l[i]); i += 1
            else:
                out.append(r[k]); k += 1
        return out + l[i:] + r[k:]
    
    print(merge([2, 9], [1, 3, 10]))
    
  2. Question 2

    What is the worst-case time complexity of merge sort?

  3. Question 3

    When does quick sort with "last element as pivot" take O(n²)?

  4. Question 4

    After a partition step of quick sort, what is guaranteed about the pivot?

  5. Question 5

    Which sort is stable?

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