Archive for February, 2008

C# Introsort

Wednesday, February 27th, 2008

Here is a C# implementation of the Introsort algorithm. Notice that the Introsort method is nearly identical to the Quicksort method. The only difference is the addition of checking for the depth limit (number of recursions -- lines 51-59); when the depth limit has been reached, the Heapsort method is called to ...

C# Heapsort

Friday, February 15th, 2008

This is a simple implementation of the Heapsort algorithm in C#. It is a max-heap implementation, meaning that it builds the heap from the bottom up by sifting down the maximum element; this is opposed to the min-heap implementation that builds the heap top-down by sifting upward. Also, this method is ...

.NET Platform Invoke (P/Invoke) Sample

Tuesday, February 12th, 2008

Recently someone asked me to help them call an unmanaged C++ DLL from a C# application, whereupon I promptly pointed them to the MSDN documentation on P/Invoke. Unfortunately (as I later learned) the documentation is very descriptive if you're trying to use a Windows DLL, but it doesn't help you ...