You are on page 1of 2

Exercice 1 

:
Bubble sort =tri a bule
1- definition 
2- Flowshart
3- Pseudo code
4- Test
5- Code source

Definition :

Bubble Sort
In this tutorial, you will learn about the bubble sort algorithm and its
implementation in Python, Java, C, and C++.

Bubble sort is a sorting algorithm that compares two adjacent elements


and swaps them until they are not in the intended order.

Just like the movement of air bubbles in the water that rise up to the
surface, each element of the array move to the end in each iteration.
Therefore, it is called a bubble sort.

Video :https://www.youtube.com/watch?v=8U5evI-dyAk
The flowshart :

def bubbleSort(nlist):
for passnum in range(len(nlist)-1,0,-1):
for i in range(passnum):
if nlist[i]>nlist[i+1]:
temp = nlist[i]
nlist[i] = nlist[i+1]
nlist[i+1] = temp

nlist = [14,46,43,27,57,41,45,21,70]
bubbleSort(nlist)
print(nlist)

You might also like