PHP and Web Technologies Freak
I spend a lot of time lurking in the channel # PHP (EFnet and freenode, please – no flame wars) and this issue is a frequently asked that the rule is a simple answer in the form of the use of strpos (), or best to ip2long () in a more than less than reply. [...]
Here is the way of quick sort in associative arrays; <? function qsort($a,$f) { qsort_do(&$a,0,Count($a)-1,$f); } function qsort_do($a,$l,$r,$f) { if ($l < $r) { qsort_partition(&$a,$l,$r,&$lp,&$rp,$f); qsort_do(&$a,$l,$lp,$f); qsort_do(&$a,$rp,$r,$f); } } function qsort_partition($a,$l,$r,$lp,$rp,$f) { $i = $l+1; $j = $l+1; while ($j <= $r) { if ($f($a[$j],$a[$l])) { $tmp = $a[$j]; $a[$j] = [...]
Quicksort is one of the fastest and simplest sorting algorithms [Hoa 62]. It works recursively by a divide-and-conquer strategy. The quicksort is considered to be very efficient, with its “divide and conquer” algorithm. This sort starts by dividing the original array into two sections (partitions) based upon the value of the first item in the array. [...]
Dijkstra’s algorithm, conceived by Dutch computer scientist Edsger Dijkstra in 1959, is a graph search algorithm that solves the single-source shortest path problem for a graph with nonnegative edge path costs, producing a shortest path tree. This algorithm is often used in routing. Algorithm Let’s call the node we are starting with an initial node. [...]