mercredi 22 août 2018

how to implement bubble sort in php with minimal complexcity?

I have an array of 5 elements. On that i want to apply bubble sort with min complexity

Currently what i am doing is

function bubbleSort(array $arr)
{
    $n = sizeof($arr);
    for ($i = 1; $i < $n; $i++) {
        for ($j = $n - 1; $j >= $i; $j--) { 
       //some fuzzy logic here
        }
      }
}

Any help ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire