Ejemplo n.º 1
0
     * Example for quick sort
     */
    public static function testForQuickSortByIteration()
    {
        $testArr = [];
        for ($i = 0; $i < 8; $i++) {
            $testArr[] = mt_rand(0, 100);
        }
        print_r($testArr);
        echo "<br>";
        print_r(self::quickSortByRecursion($testArr));
        echo "<br>";
        print_r(self::quickSortByIteration($testArr));
        echo "<br>";
    }
    /**
     * To find the kth smallest element in an unordered list.
     */
    public static function quickSelect($array)
    {
    }
    /**
     * Used for quickSelect
     */
    private static function partition($list, $left, $right, $pivotIndex)
    {
        //        $pivotValue = $list[];
    }
}
Algo::testForQuickSortByIteration();
Ejemplo n.º 2
0
<?php

header("content-type:text/html; charset=utf-8");
include 'permission.php';
require_once 'include/smarty_setup.php';
require_once 'include/db_operator_class.php';
date_default_timezone_set('PRC');
$smarty = new Algo();
//$week=$_SESSION['week'];
$week = getWeek();
$team = $_SESSION['team'];
if (isset($_GET['current_week'])) {
    $current_week = $_GET['current_week'];
    if ($current_week <= 0) {
        $current_week = 1;
    }
    if ($current_week > $week) {
        $current_week = $week;
    }
} else {
    $current_week = $week;
}
if (isset($_GET['level'])) {
    $level = $_GET['level'];
    $group = $level;
    $problems = get_ProblemsOnWeek($current_week, $level);
} else {
    $group = $team;
    $problems = get_ProblemsOnWeek($current_week, $team);
}
if ($problems != null) {