Revision 2 of 3, by WikiArchive on 11-4-2026. The page as it is now.
Bubble sort/fr
Le tri à bulle est un algorithme de tri simple.
Contents
- 1 Propriétés
- 2 Unité UBubbleSort
- 3 Exemple d'emploi
- 4 Voir aussi
Propriétés
- Très lent
- Adapté seulement pour trier des données en petite quantité
- Rapide seulement quand le tableau est presque trié
Unité UBubbleSort
unit UBubbleSort;
interface
type
// data type
TItemBubbleSort=integer;
procedure BubbleSort( var a: array of TItemBubbleSort );
implementation
procedure swap( var a, b:TItemBubbleSort );
var
temp : TItemBubbleSort;
begin
temp := a;
a := b;
b := temp;
end;
procedure BubbleSort( var a: array of TItemBubbleSort );
var
n, newn, i:integer;
begin
n := high( a );
repeat
newn := 0;
for i := 1 to n do
begin
if a[ i - 1 ] > a[ i ] then
begin
swap( a[ i - 1 ], a[ i ]);
newn := i ;
end;
end ;
n := newn;
until n = 0;
end;
end.Exemple d'emploi
uses
UBubbleSort
...
var
a: array[0..100] of integer;
begin
...
BubbleSort(a);
...Voir aussi
From the Free Pascal wiki, page "Bubble sort/fr", as the Internet Archive kept it on 2023-03-30. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
