Student Name: Adomas Zilickij Student Number: 20059569

Bubble Sort

Bubble sort is a type of sorting algorithm. It works by going through the array multiple times (passes), comparing adjacent elements and swapping them if they are in the wrong order. After each pass, the largest element moves to the end, which is its final position. In each pass, we don't need to look at the elements that are already in their final positions - we only work with the remaining elements. Bubble sort is not efficient for large data sets due to its time complexity of O(n2) in the worst-case scenario.

Compare Swap Unsorted Sorted

Enhance with AI

Pseudocode

n = arrayValues.length - 1
currentIndex = 0
WHILE n > 0:
WHILE currentIndex < n:
IF arrayValues[currentIndex] > arrayValues[currentIndex + 1]:
SWAP arrayValues[currentIndex], arrayValues[currentIndex + 1]
END IF
currentIndex = currentIndex + 1
END WHILE
currentIndex = 0
n = n - 1
END WHILE