airfocus-logoGlossary
airfocus search exit

Book a demo

Product Management

Bubble Sort

CONTENTS

What is bubble sort?

💬

Definition of bubble sort

Bubble sort is one of the fundamental forms of sorting in programming. Bubble sort algorithms move through a sequence of data (typically integers) and rearrange them into ascending or descending order one number at a time. To do this, the algorithm compares number X to the adjacent number Y. If X is higher than Y, the two are swapped and the algorithm starts over.

This process repeats until the entire range of numbers has been sorted in the desired order. For instance, if you were trying to arrange [1, 3, 2, 4] into ascending order, the bubble sort algorithm would run once, swapping the 3 with the 2. 

In another matrix, however, your numbers might look like this: [3, 1, 4, 2]. In this case, the algorithm would run three times, swapping the 3 and the 1 the first time, then the 4 and the 2 the second time, and finally the 3 and the 2. 

eBook

All You Need To Know About Product Management

Read now
CTA eBook image background
airfocus eBook All You Need To Know About Product Management

What does bubble sort mean?

The name bubble sort comes from the fact that smaller or larger elements "bubble" to the top of a dataset. In the previous example of [3, 1, 4, 2], the 3 and 4 are bubbling up the dataset to find their proper positions.

This algorithm is alternatively called the sinking sort for the opposite reason; some of the elements are sinking to the bottom of the dataset. In our example, the 1 and the 2 are sinking elements. 

Advantages of using bubble sort

Bubble sort's strong point is its simplicity. It takes just a few lines of code, is easy to read, and can be plugged in anywhere in your program. However, it's extremely inefficient for larger sets of numbers and should be used accordingly. 

bubble sort

General FAQ

What is bubble sort?
Bubble sort is a simple sorting algorithm used to rearrange a set of elements in ascending or descending order. It's useful for smaller sets of elements but is inefficient for larger sets.
Why is bubble sort called bubble sort?
Bubble sort gets its name from the fact that data "bubbles" to the top of the dataset. Bubble sort is alternatively called "sinking sort" for the opposite reason, which is that some elements of data sink to the bottom of the dataset.
airfocus eBook All You Need To Know About Product Management
eBook
All You Need To Know About Product Management
Read now

Glossary categories

Agile

Agile

Feedback Management

Feedback Management

Prioritization

Prioritization

Product Management

Product Management

Product Strategy

Product Strategy

Roadmapping

Roadmapping

Experience the new
way of doing product
management

Book a demo

airfocus modular platform

Experience the new
way of doing product
management

airfocus modular platform
Top rated
on major platforms
g2 badge users love us
g2 badge leader fall 2024
GetApp badge category leader
software advice badge
capterra shortlist badge
proddy roadmapping
crozdesk quality choice
Company
All rights reserved. contact@airfocus.com
DEFR