Researching Searching Algorithms?
NiN3x asks: "I have recently written a sorting algorithm that can be close to four times as fast as quicksort and never much slower. I was wondering if there are lots of sorting algorithms like this out there. I don't think I could be the only one that has thought of something like this. I am only in my second year of computer science, so I don't know a lot about these things. I have tried searching the net and can't find anything. My algorithm is NOT an inplace sorting algorithm. Can anyone point me to some sources for this type of thing?"
Ok, given the overwhelming response requesting my sorting algorithm I have decided to post it here for your review. Please note that this is the culmination of my lifetime's accomplishments so treat this intellectual property with all due respect.
// For each spot in the array // (starting at the top) // Walk through the array to that spot // At each location, compare the two adjacent elements // Swapp elements as needed
-- pseudoCode to follow --
This function sorts the array into ascending order (lowest..highest). The algorithm walks through the array bubbling the biggest number up to the top. It then goes through again for the next biggest and so on until it has done the entire thing.
void bubble_sort(long thearray[], int sizeofarray)
{
int i,j;
long temp;
for(i=sizeofarray; i>=0; --i)
{
for(j=0; i>j; j++)
{
if(thearray[j] > thearray[j+1])
{
temp = thearray[j];
thearray[j] = thearray[j+1];
thearray[j+1] = temp;
}
}
}
return;
}
Glonoinha the MebiByte Slayer