Bubble sort is a very simple algorithm for sorting used by beginners in computer science. The algorithm compares each pair of adjacent elements and switches their positions if they are in reverse order, repeating the process until the array is completely sorted. The algorithm is inefficient for large sets of data because its complexity is .