Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Bubble Sort

Bubble sort is a naive sorting algorithm.

The concept

The concept

  • Imagine that you have a set of cards face up on the desk.
  • If the first two cards are in the wrong order, you swap them.
  • Then do the same for the second and third cards, and continue in this pattern until the end of the pack. This is known as a pass.
  • The highest value will 'bubble' up to the top of the pack each pass.
  • By repeating this enough times, the pack will get sorted.
In English

In English

  • Compare the first two items of the dataset:
    • If they are in the wrong order, swap them.
  • Continue for the rest of the cards in the deck.
  • Repeat the whole process, until a pass with no swaps happens.
Pros and cons of bubble sort

Pros and cons of bubble sort

  • Pros:
    • Easy to implement.
    • Does not use much memory.
  • Cons:
    • Poor for efficiency.
Jump to other topics
1

Computational Thinking & Algorithms

2

Programming

3

Hardware & Software

4

Data

5

The Internet

6

Online Safety & Security

Practice questions on Bubble Sort

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
  3. 3
Answer all questions on Bubble Sort

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium