Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 can i have all kind of sort please
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
siczy




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
AsianSensation




PostPosted: Tue Nov 25, 2003 7:26 pm   Post subject: (No 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
Andy




PostPosted: Tue Nov 25, 2003 7:28 pm   Post subject: (No 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
Tony




PostPosted: Tue Nov 25, 2003 7:32 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
AsianSensation




PostPosted: Tue Nov 25, 2003 8:00 pm   Post subject: (No subject)

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




PostPosted: Tue Nov 25, 2003 8:01 pm   Post subject: (No subject)

why sort it? use binary tree!
Tony




PostPosted: Tue Nov 25, 2003 8:03 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Tue Nov 25, 2003 8:05 pm   Post subject: (No subject)

LOL, i see that derek is getting popular already...
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Tue Nov 25, 2003 9:37 pm   Post subject: (No 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!
siczy




PostPosted: Tue Nov 25, 2003 9:38 pm   Post subject: (No subject)

wat bout the inserting sort one?anyone know about that one?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: