
-----------------------------------
siczy
Tue Nov 25, 2003 7:00 pm

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~ :lol:

-----------------------------------
AsianSensation
Tue Nov 25, 2003 7:26 pm


-----------------------------------
bubble sort:

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

-----------------------------------
Andy
Tue Nov 25, 2003 7:28 pm


-----------------------------------
bubble sort:

for i : 1 .. n
    for j : i .. n + 1

    end for
end for
nope
should be
for i : 1 .. n - 1
    for j : i .. n

    end for
end for

-----------------------------------
Tony
Tue Nov 25, 2003 7:32 pm


-----------------------------------
:roll:

anyways... [url=http://www.compsci.ca/v2/search.php]Search function is [url=http://www.compsci.ca/v2/viewtopic.php?t=447&highlight=bubble+sort]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 :lol:

-----------------------------------
AsianSensation
Tue Nov 25, 2003 8:00 pm


-----------------------------------
just how many types of sorting are there? And which ones are the most efficient?

-----------------------------------
Andy
Tue Nov 25, 2003 8:01 pm


-----------------------------------
why sort it? use binary tree!

-----------------------------------
Tony
Tue Nov 25, 2003 8:03 pm


-----------------------------------
well there got to be like a dozen of variations of bubble sort :lol:

Most efficient is quick-sort.

Dodge - yes... binary tree... here's one for you

void binaryTree () 
{ 
cout 