Skip to content

Instantly share code, notes, and snippets.

@alherd-by
Created March 23, 2016 10:28
Show Gist options
  • Save alherd-by/6060ac68391f1d7ef0f9 to your computer and use it in GitHub Desktop.
Save alherd-by/6060ac68391f1d7ef0f9 to your computer and use it in GitHub Desktop.
<?php
require_once 'HastTable.php';
const LENGTH = 20;
$hs1 = generate();
var_dump($hs1);
$hs1->bucketSort();
var_dump($hs1);
echo str_repeat('=', 150) . PHP_EOL;
echo str_repeat('=', 150) . PHP_EOL;
echo str_repeat('=', 150) . PHP_EOL;
$hs2 = generate();
var_dump($hs2);
$hs2->selectionSort();
var_dump($hs2);
function generate(){
$division = function ($key) {
return $key % LENGTH;
};
$hastTableDiv = new HastTable($division);
for ($i = 0; $i < LENGTH; $i++) {
$key = random_int(1000000000000, 9999999999999);
$hastTableDiv[$key] = random_int(-100, 100);
}
return $hastTableDiv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment