Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
|
|
@ -0,0 +1,20 @@
|
|||
bubble_sort(u) := block(
|
||||
[n: length(u), swapped: true, temp],
|
||||
while swapped do (
|
||||
swapped: false,
|
||||
for i: 1 thru n - 1 do (
|
||||
if u[i] > u[i + 1] then (
|
||||
temp: u[i],
|
||||
u[i]: u[i + 1],
|
||||
u[i + 1]: temp,
|
||||
swapped: true
|
||||
)
|
||||
)
|
||||
),
|
||||
u
|
||||
);
|
||||
/* Example */
|
||||
/* sample:[3,65,6,24,24,89,2,59,6]$
|
||||
bubble_sort(%);
|
||||
[2,3,6,6,24,24,59,65,89]
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue