Category Archives: php

Insertion sort php

<?php /** * An unsorted list of integers * Worst case O(n^2) * Best case O(n) * @param array $unsorted */ function insertionSort(array &$unsorted){ for($i = 1; $i < count($unsorted); $i++){ $temp = $unsorted[$i]; $j = $i – 1; while … Continue reading

Posted in algorithms, php | Leave a comment