Quicker then QuickSort???
From: madler (anonymous_at_discussions.microsoft.com)
Date: 05/10/04
- Next message: Mark Broadbent: "Re: Standards"
- Previous message: Jack David: "File System Monitor Question"
- Next in thread: Mathieu Chavoutier: "Re: Quicker then QuickSort???"
- Reply: Mathieu Chavoutier: "Re: Quicker then QuickSort???"
- Reply: Kristofer Gafvert: "Re: Quicker then QuickSort???"
- Reply: Doknjas: "re:Quicker then QuickSort???"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 10 May 2004 08:36:07 -0700
Hi.
I might be a bit niave here but I was looking over a quicksort implementation (provide by compuware as a sample for DevPartner Profiler community edition) and I thought that I could do better then that. So I implemented my own simple sorting algoritim and it seems to run twice as fast as the quicksort.
So my question is - What is the catch with my algorithim - why do all libraries include the very complex QuickSort when something as simple as what I did is not used. I am sure that people have explored the same method before. Does anyone know what it's shortcomes are?
Here is the method:
int lval,lpos;
int hval,hpos;
lpos = 0;
hpos = 0;
lval = 1000000;
hval = 0;
for (int i = 0 ;i<(numElems /2);i++)
{
flag = false;
int j;
lval = hval;
hval = 0;
for (j = i;j<((numElems -i)-1);j++)
{
int c = Elements[j];
if (c < lval)
{
lpos = j;
lval = c;
}
if (c > hval)
{
hpos = j;
hval = c;
}
}
SwapEm(i,lpos);
SwapEm(j,hpos);
}
Thanks
- Next message: Mark Broadbent: "Re: Standards"
- Previous message: Jack David: "File System Monitor Question"
- Next in thread: Mathieu Chavoutier: "Re: Quicker then QuickSort???"
- Reply: Mathieu Chavoutier: "Re: Quicker then QuickSort???"
- Reply: Kristofer Gafvert: "Re: Quicker then QuickSort???"
- Reply: Doknjas: "re:Quicker then QuickSort???"
- Messages sorted by: [ date ] [ thread ]