Login   Register  
PHP Classes
elePHPant
Icontem

Just a remark

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Sort Algorithms  >  All threads  >  Just a remark  >  (Un) Subscribe thread alerts  
Subject:Just a remark
Summary:implementing efficient algorithms in PHP is not possible
Messages:2
Author:Fabian Schmengler
Date:2013-01-04 20:11:46
Update:2013-01-04 20:55:51
 

  1. Just a remark   Reply   Report abuse  
Picture of Fabian Schmengler
Fabian Schmengler
2013-01-04 20:11:46
PHP Arrays are not a sensible data structure for such things. While implementing sorting algorithms is a good exercise, your functions have little use in a real application.

Fun Fact: I extended your test script to compare the results with sort(). On this data the internal quicksort of PHP performs 30 times faster than your implementation. Nothing wrong with your code, that's just because PHP does not give you access to low level data structures (though you might give it a try with SplFixedArray, which at least uses real arrays, not hashtables).

  2. Re: Just a remark   Reply   Report abuse  
Picture of catalin
catalin
2013-01-04 20:55:51 - In reply to message 1 from Fabian Schmengler
You are so right!
Was just an exercise to see how is working different sorting algorithms in PHP.
And actually I wanted to compare those algorithms in PHP as relative performance (I didn't have intention to compare with same algorithms in C).

So take it as an exercise.