Results 1 to 2 of 2

Thread: .NET Implementation of the quicksort algorthm on various arrays.

  1. #1

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    .NET Implementation of the quicksort algorthm on various arrays.

    Hi All,

    Here is a simple class to sort an array of char, integer, or strings using the quicksort algorithm, which works very fast on large groups of items, in the manner described below:
    Quote Originally Posted by http://linux.wku.edu/~lamonml/algor/sort/quick.html
    The recursive algorithm consists of four steps (which closely resemble the merge sort):
    1. If there are one or less elements in the array to be sorted, return immediately.
    2. Pick an element in the array to serve as a "pivot" point. (Usually the left-most element in the array is used.)
    3. Split the array into two parts - one with elements larger than the pivot and the other with elements smaller than the pivot.
    4. Recursively repeat the algorithm for both halves of the original array.
    I didn't come up with this method, but it works great. Attatched is a .NET Project to build the DLL, as well as a precompiled DLL with Documentation. The method is called using the following:
    VB Code:
    1. ArrayVariable = QuickSort(ArrayVariableName, [i]Ascending as Boolean(Optional)[/i])

    There are 6 overloads, two each for char, string, and integer. (With the option to use descending order as an available overload for each). XML Comments are used, and pre-compiled by the NDoc Documentation tool , and tested inside VS 2003.

    I mostly did this as a self learning experience, with sorting, and overloads, and XML commenting, but feel free to use it if you can, bash it if you must, and ignore it in all likelyhood

    Bill
    Attached Files Attached Files
    Last edited by Hack; Jan 13th, 2006 at 10:02 AM.
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  2. #2

    Thread Starter
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: .NET Implementation of the quicksort algorthm on various arrays.

    Well Like I said, this was a learning experience. The Icomparable Interface and the Array.Sort method are about 7 times faster. Now, I get to learn interfaces Still, i'll leave it up, as I suppose it's not AWFUL coding or anything

    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width