comparison tests/farray-array.t @ 779:0bb535e50271

farray.sh: Implement Heapsort in the "bottom-up" implementation. BUGS: A little bit slower than the "standard" implementation.
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 26 Oct 2024 13:52:25 +0200
parents 84527b00d29a
children 11f3101c1980
comparison
equal deleted inserted replaced
778:84527b00d29a 779:0bb535e50271
1407 DEBUG: 3: `4' 1407 DEBUG: 3: `4'
1408 DEBUG: 4: `5' 1408 DEBUG: 4: `5'
1409 $ farray_release TEST 1409 $ farray_release TEST
1410 $ check_no_array_artifacts 1410 $ check_no_array_artifacts
1411 1411
1412 $ farray_create TEST 5 3 2 4
1413 $ farray_heapsort_bottomup TEST
1414 $ check_array_is_sorted "$TEST"
1415 $ farray_debug TEST
1416 DEBUG: array `TEST' has length 4
1417 DEBUG: the items:
1418 DEBUG: 1: `2'
1419 DEBUG: 2: `3'
1420 DEBUG: 3: `4'
1421 DEBUG: 4: `5'
1422 $ farray_release TEST
1423 $ check_no_array_artifacts
1424
1412 $ create_random_array UNSORTED 1000 1425 $ create_random_array UNSORTED 1000
1413 $ check_array_is_sorted "$UNSORTED" 1426 $ check_array_is_sorted "$UNSORTED"
1414 [1] 1427 [1]
1415 1428
1416 $ farray_create TEST 1429 $ farray_create TEST
1435 [1] 1448 [1]
1436 $ farray_heapsort TEST 1449 $ farray_heapsort TEST
1437 $ check_array_is_sorted "$TEST" 1450 $ check_array_is_sorted "$TEST"
1438 $ farray_release TEST 1451 $ farray_release TEST
1439 1452
1453 $ farray_create TEST
1454 $ farray_splice "" TEST 1 "" UNSORTED
1455 $ check_array_is_sorted "$TEST"
1456 [1]
1457 $ farray_heapsort_bottomup TEST
1458 $ check_array_is_sorted "$TEST"
1459 $ farray_release TEST
1460
1440 $ farray_release UNSORTED 1461 $ farray_release UNSORTED
1441 $ check_no_array_artifacts 1462 $ check_no_array_artifacts
1442 1463
1443 # Extra checks for Heapsort 1464 # Extra checks for Heapsort
1444 1465
1445 $ farray_create UNSORTED '189548216' '544226607' '690563482' '224884577' '843524724' '922143089' '917031008' '602352555' '397442038' '350475285' 1466 $ farray_create UNSORTED '189548216' '544226607' '690563482' '224884577' '843524724' '922143089' '917031008' '602352555' '397442038' '350475285'
1467
1446 $ farray_create TEST 1468 $ farray_create TEST
1447 $ farray_splice "" TEST 1 "" UNSORTED 1469 $ farray_splice "" TEST 1 "" UNSORTED
1448 $ farray_heapsort TEST 1470 $ farray_heapsort TEST
1449 $ check_array_is_sorted "$TEST" 1471 $ check_array_is_sorted "$TEST"
1450 1472 $ farray_release TEST
1451 $ farray_release TEST 1473
1474 $ farray_create TEST
1475 $ farray_splice "" TEST 1 "" UNSORTED
1476 $ farray_heapsort_bottomup TEST
1477 $ check_array_is_sorted "$TEST"
1478 $ farray_release TEST
1479
1452 $ farray_release UNSORTED 1480 $ farray_release UNSORTED
1453 $ check_no_array_artifacts 1481 $ check_no_array_artifacts
1454 1482
1455 1483
1456 Binary Search 1484 Binary Search
1915 1943
1916 No Locals 1944 No Locals
1917 ========= 1945 =========
1918 1946
1919 $ check_no_local_artifacts 1947 $ check_no_local_artifacts
1948
1949 $ set