Computer Science Canada

can i have all kind of sort please

Author:  siczy [ Tue Nov 25, 2003 7:00 pm ]
Post subject:  can i have all kind of sort please

i'm doing a sorting program for Computer Science Class~I need the code for bubble sort,quick sort,inserting sort~please help me~thanks~ Laughing

Author:  AsianSensation [ Tue Nov 25, 2003 7:26 pm ]
Post subject: 

bubble sort:

code:
for i : 1 .. n
    for j : i .. n + 1

    end for
end for


where n + 1 is the number of elements in the array that is to be sorted

take that andy

Author:  Andy [ Tue Nov 25, 2003 7:28 pm ]
Post subject: 

AsianSensation wrote:
bubble sort:

code:
for i : 1 .. n
    for j : i .. n + 1

    end for
end for

nope
should be
code:
for i : 1 .. n - 1
    for j : i .. n

    end for
end for

Author:  Tony [ Tue Nov 25, 2003 7:32 pm ]
Post subject: 

Rolling Eyes

anyways... Search function is good

Quick sort is more complicated. It has to do with breaking the array in halfs (its a self calling function) and comparing little bits. I dont remember. VB has it already writen for you Laughing

Author:  AsianSensation [ Tue Nov 25, 2003 8:00 pm ]
Post subject: 

just how many types of sorting are there? And which ones are the most efficient?

Author:  Andy [ Tue Nov 25, 2003 8:01 pm ]
Post subject: 

why sort it? use binary tree!

Author:  Tony [ Tue Nov 25, 2003 8:03 pm ]
Post subject: 

well there got to be like a dozen of variations of bubble sort Laughing

Most efficient is quick-sort.

Dodge - yes... binary tree... here's one for you
code:

void binaryTree ()
{
cout << " 000";
cout << "0000";
cout << " 000";
cout << " 11";
cout << " 11";
}


props to Dauntless for the source code Laughing

Author:  Andy [ Tue Nov 25, 2003 8:05 pm ]
Post subject: 

LOL, i see that derek is getting popular already...

Author:  Mazer [ Tue Nov 25, 2003 9:37 pm ]
Post subject: 

tony wrote:

Dodge - yes... binary tree... here's one for you
code:

void binaryTree ()
{
cout << " 000";
cout << "0000";
cout << " 000";
cout << " 11";
cout << " 11";
}


lmao, good stuff!

Author:  siczy [ Tue Nov 25, 2003 9:38 pm ]
Post subject: 

wat bout the inserting sort one?anyone know about that one?


: