Skip to content

hrid0yyy/Bubble-Sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Bubble Sort Algorithm

The Bubble Sort algorithm is a simple comparison-based sorting technique. It repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. This process is repeated until the entire list is sorted.

Key Characteristics:

Time Complexity: O(n²) in the average and worst cases, where n is the number of elements.

Space Complexity: O(1) (in-place sorting).

Work Flow:

Compare adjacent elements in the list. Swap them if they are in the wrong order. Repeat this process for all elements until no more swaps are needed.

Example: For a list of integers: [5, 2, 9, 1, 5, 6]

First Pass: [2, 5, 1, 5, 6, 9] Second Pass: [2, 1, 5, 5, 6, 9] Continue until sorted: [1, 2, 5, 5, 6, 9]

About

A Sorting Algorithm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages