Algorithm Category

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.
Unfortunately, [...]

Quick sort for associative arrays

In: Algorithm, Off Topic, PHP

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);
[...]

Sorting algorithm- Quicksort

In: Algorithm

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 [...]

Dijkstra’s algorithm

In: Algorithm

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. Let [...]


Sponsors