comparison tests/farray-array.t @ 778:84527b00d29a

farray.sh: Implement Heapsort in the "standard" implementation. BUGS: Performance here equals Shellsort.
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 25 Oct 2024 20:29:04 +0200
parents 75a8b69c04f0
children 0bb535e50271
comparison
equal deleted inserted replaced
777:3f9b22ddacb8 778:84527b00d29a
1394 DEBUG: 3: `4' 1394 DEBUG: 3: `4'
1395 DEBUG: 4: `5' 1395 DEBUG: 4: `5'
1396 $ farray_release TEST 1396 $ farray_release TEST
1397 $ check_no_array_artifacts 1397 $ check_no_array_artifacts
1398 1398
1399 $ farray_create TEST 5 3 2 4
1400 $ farray_heapsort TEST
1401 $ check_array_is_sorted "$TEST"
1402 $ farray_debug TEST
1403 DEBUG: array `TEST' has length 4
1404 DEBUG: the items:
1405 DEBUG: 1: `2'
1406 DEBUG: 2: `3'
1407 DEBUG: 3: `4'
1408 DEBUG: 4: `5'
1409 $ farray_release TEST
1410 $ check_no_array_artifacts
1411
1399 $ create_random_array UNSORTED 1000 1412 $ create_random_array UNSORTED 1000
1400 $ check_array_is_sorted "$UNSORTED" 1413 $ check_array_is_sorted "$UNSORTED"
1401 [1] 1414 [1]
1402 1415
1403 $ farray_create TEST 1416 $ farray_create TEST
1414 [1] 1427 [1]
1415 $ farray_shellsort TEST 1428 $ farray_shellsort TEST
1416 $ check_array_is_sorted "$TEST" 1429 $ check_array_is_sorted "$TEST"
1417 $ farray_release TEST 1430 $ farray_release TEST
1418 1431
1432 $ farray_create TEST
1433 $ farray_splice "" TEST 1 "" UNSORTED
1434 $ check_array_is_sorted "$TEST"
1435 [1]
1436 $ farray_heapsort TEST
1437 $ check_array_is_sorted "$TEST"
1438 $ farray_release TEST
1439
1440 $ farray_release UNSORTED
1441 $ check_no_array_artifacts
1442
1443 # Extra checks for Heapsort
1444
1445 $ farray_create UNSORTED '189548216' '544226607' '690563482' '224884577' '843524724' '922143089' '917031008' '602352555' '397442038' '350475285'
1446 $ farray_create TEST
1447 $ farray_splice "" TEST 1 "" UNSORTED
1448 $ farray_heapsort TEST
1449 $ check_array_is_sorted "$TEST"
1450
1451 $ farray_release TEST
1419 $ farray_release UNSORTED 1452 $ farray_release UNSORTED
1420 $ check_no_array_artifacts 1453 $ check_no_array_artifacts
1421 1454
1422 1455
1423 Binary Search 1456 Binary Search