Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / C#

Iterative Quick Sort

Rate me:
Please Sign up or sign in to vote.
3.61/5 (7 votes)
25 Jan 2008CPOL3 min read 60.9K   281   14  
An iterative implementation of Quicksort
using System;
using System.Runtime.InteropServices;

namespace IterativeQuickSort
{
    class Stopwatch
    {
        [DllImport("kernel32.dll")]
        extern static short QueryPerformanceCounter(ref long x);

        [DllImport("kernel32.dll")]
        extern static short QueryPerformanceFrequency(ref long x);

        private static double strt;
        public static double time;

        public static void Start()
        {
            long cnt = 0;
            long frq = 0;
            QueryPerformanceCounter(ref cnt);
            QueryPerformanceFrequency(ref frq);
            strt = (double)cnt / (double)frq;
        }

        public static void Stop()
        {
            long cnt = 0;
            long frq = 0;
            QueryPerformanceCounter(ref cnt);
            QueryPerformanceFrequency(ref frq);
            double c = (double)cnt / (double)frq;
            time = (c - strt) * 1000;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions