Professional Documents
Culture Documents
Al-Balqa Applied University ةيقيبطتلا ءاقلبلا ةعماج: Prof. Oqeili Saleh Lectures
Al-Balqa Applied University ةيقيبطتلا ءاقلبلا ةعماج: Prof. Oqeili Saleh Lectures
Sorting Methods
Bubble Sort
Bubble sort (sinking sort.)
Bubble sort is a simple sorting algorithm which compares the adjacent
elements in an array and swaps them if they are in the wrong order.
#Python Program for Bubble Sort
arr=[7,5,9,3,6,2,1] Output:
Sorted Array : [1, 2, 3, 5, 6,7,9]
n=len(arr)
for i in range(n):
for j in range(0, n-i-1): O( )