Skip to content

TheQueryCrew/P2-BubbleSort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bubble Sort

Write a function to sort an array of n elements.

Bubble Sort:

Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The time complexity is O(n²) in the average case.

Input:

arr = [2,1,6,4,9,7,5]

Output:

arr = [1,2,4,5,6,7,9]

Time Complexity:

O(n²)

Releases

Packages

Contributors

Languages