Take Offline

Array V. linked list.
A few years ago, in yet another CS Class, I had to do a number of benchmarks on algorithms. One that is relevant to this discussion is array's versus linked lists.

The arrays and ll's were not large, a few hundred kb each, so that they fit easily within ram. When benchmarking completion time of various sorts, the arrays beat the algorithm out of the linked list - every time with an equivalent sort.

The array sits in a contiguous bock of ram where as who knows where the LL sits. While electricity operates at near light speed, it is not light speed and while gate switching to read ram operates near electrical speed, it is not electrical speed; it is more like a logarithmic speed.

The test units were set up to read the clock both at the beginning and end of program execution. The code was first written in Java, later C++, followed by C. I will grant that the language had a little to do with how fast the sort operated because not all algorithms operate efficiently, but the general case was also true for highly optimized algorithms. And yes, the Professor was angry when I wrote a poor example of an assembly sort (with Olly debug) that beat his best, highly optimized, C algorithms. But that was a side issue that I was challenged to prove when I stated baldly that machine code is much faster than compiled languages.

Also, I might add, that when you code for a Windows environment, your code can not be as efficient as it would be in a more pure and less bloated environment.
Posted by normhaga@...
Updated - 15th Oct 2008

Would you like to take this discussion to the Water Cooler?

No Thanks