Ejemplo n.º 1
0
    public static function demo()
    {
        /**
         * Demo data:
         *
         * $arr = [];
         * for($i=0; $i<100; $i++)
         *   $arr[] = $i;
         * shuffle($arr);
         */
        $arr = [1, 3, 5, 2, 9, 10, 1];
        $new = ITSP::mergeSort($arr);
        var_dump($new);
        exit;
        $new = ITSP::insertSort($arr);
        var_dump($new);
        exit;
        $new = ITSP::selectSort($arr);
        var_dump($new);
        exit;
        $new = ITSP::bubbleSort($arr);
        $count = count($new);
        var_dump($new);
        $val = 5;
        print self::binarySearch($new, $val, 0, $count - 1);
        $val = 7;
        print self::binaerSearchIterative($new, $val, 0, $count - 1);
    }
}
ITSP::demo();