RG's E-Learning Centre · Book a free demo class · WhatsApp +91-9379416374

Bubble sort passes: Class 11 practice

Bubble sort compares neighbours and swaps them if they are in the wrong order. Read the method, follow the three worked examples, then try the six questions.

What you should know first

  • Lists

The idea behind bubble sort passes

Bubble sort compares neighbours and swaps them if they are in the wrong order. After pass k, the k largest values are in their final places at the end.

Step-by-step method

  1. Compare positions 0–1, 1–2, … swapping when left > right.
  2. One full sweep is a pass.
  3. Repeat; stop early if a pass makes no swaps.

Worked example 1 (Basic)

Apply 1 pass of bubble sort (ascending) to [13, 25, 21, 23, 51]. Give the list and the number of swaps.

  1. After 1 pass(es): [13, 21, 23, 25, 51]
  2. Swaps: 2
  3. Answer: [13, 21, 23, 25, 51], 2 swaps

Worked example 2 (Standard)

Apply 2 passes of bubble sort (ascending) to [32, 39, 34, 53, 7, 42]. Give the list and the number of swaps.

  1. After 2 pass(es): [32, 34, 7, 39, 42, 53]
  2. Swaps: 4
  3. Answer: [32, 34, 7, 39, 42, 53], 4 swaps

Worked example 3 (Challenge)

Apply 3 passes of bubble sort (ascending) to [14, 3, 59, 46, 23, 5, 13]. Give the list and the number of swaps.

  1. After 3 pass(es): [3, 14, 5, 13, 23, 46, 59]
  2. Swaps: 10
  3. Answer: [3, 14, 5, 13, 23, 46, 59], 10 swaps

Common mistakes and misconceptions

  • Thinking one pass sorts the list
  • Forgetting the last k items are already fixed

Practice questions

  1. (Basic) Apply 1 pass of bubble sort (ascending) to [27, 34, 30, 50, 58]. Give the list and the number of swaps.
  2. (Basic) Apply 1 pass of bubble sort (ascending) to [14, 1, 46, 14, 12]. Give the list and the number of swaps.
  3. (Standard) Apply 2 passes of bubble sort (ascending) to [49, 9, 38, 20, 29, 55]. Give the list and the number of swaps.
  4. (Standard) Apply 2 passes of bubble sort (ascending) to [60, 41, 5, 32, 42, 17]. Give the list and the number of swaps.
  5. (Challenge) Apply 3 passes of bubble sort (ascending) to [12, 44, 51, 23, 16, 34, 28]. Give the list and the number of swaps.
  6. (Challenge) Apply 3 passes of bubble sort (ascending) to [13, 23, 5, 28, 40, 6, 14]. Give the list and the number of swaps.

Answer key with full working

  • Q1: After 1 pass(es): [27, 30, 34, 50, 58] → Swaps: 1 → Answer: [27, 30, 34, 50, 58], 1 swaps
  • Q2: After 1 pass(es): [1, 14, 14, 12, 46] → Swaps: 3 → Answer: [1, 14, 14, 12, 46], 3 swaps
  • Q3: After 2 pass(es): [9, 20, 29, 38, 49, 55] → Swaps: 6 → Answer: [9, 20, 29, 38, 49, 55], 6 swaps
  • Q4: After 2 pass(es): [5, 32, 41, 17, 42, 60] → Swaps: 8 → Answer: [5, 32, 41, 17, 42, 60], 8 swaps
  • Q5: After 3 pass(es): [12, 16, 23, 28, 34, 44, 51] → Swaps: 10 → Answer: [12, 16, 23, 28, 34, 44, 51], 10 swaps
  • Q6: After 3 pass(es): [5, 13, 6, 14, 23, 28, 40] → Swaps: 8 → Answer: [5, 13, 6, 14, 23, 28, 40], 8 swaps

Syllabus note

This skill is listed under "Sorting" for Class 11 in the NCERT/CBSE books. ICSE, IGCSE, IB and state boards may teach it in a different chapter or year.

Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.

Related practice and notes

Frequently asked questions

Which chapter is bubble sort passes in?

"Sorting", Class 11 Computer Science (NCERT/CBSE). Other boards may place it differently.

How were the answers checked?

Answers on this page are generated and automatically re-checked by a second, independent calculation. They have not been reviewed by a teacher — if you spot a problem, tell us on WhatsApp.

Book a free demo class