Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Sorting algorithm
Author Message
Mikez

Posted: Fri Dec 13, 2002 12:32 pm   Post subject: Sorting algorithm

plz tell or show me an advanced form of Sorting algorithms (not bubble) for me to use. include code if possible.

FizixMan

Posted: Fri Dec 13, 2002 1:09 pm   Post subject: (No subject)

Helps if we knew what we were sorting, and how they are to be sorted.
Mikez

Posted: Fri Dec 13, 2002 7:39 pm   Post subject: Sorting

I will be sorting the scores of players in a game
eg.
mike's score is 100
etc

they need to be sorted from highest to lowest or vice verse
Mikez

Posted: Fri Dec 13, 2002 7:42 pm   Post subject: (No subject)

also the more advanced the better but if u can please give a couple.
(if you have the time)

thanx u guys are a HUGE help. keep up the good work
FizixMan

Posted: Fri Dec 13, 2002 10:55 pm   Post subject: (No subject)

Well... I'm assuming you'll be inputing a number of scores.. I'm also assuming you know how man scores to be inputed. Now, I could write code for you to pretty much make a dynamic sized array... but that would probably be more than your teacher or yourself are really capable of (so I'm not going to make it that advanced for you) in fact, I'm going to help out with the basics, you can get that working... and if you have any ideas on how to make it more advanced, well ask and we'll see if we can help you...

but this deal with people just asking for the complete source code to class homework and projects is pretty lame... and believe me... all offense intended j/k Again... keep asking for the code if you want, I don't intend to just write it for you (even though I always do write the program to make sure what I'm giving you works... so easy to just copy paste the code... but it's so much better that you all learn how to code it from scratch)

okay, well... if you know how many scores are being put in, just declare an array of integers with that many elements. Then you'll want a "for loop" to go through the scores and sort them... also, I'm assuming you'll just want these outputted to the screen and not restored in an array... if you want them stored in an array, just change the part where it prints to the screen with a line that saves it to an array element.

 code: declare array of integers with size N declare variable X as integer with value 0  %to be used to sort declare variable Y as integer %to be used to remember which scores are used user inputs scores to each element for c:1..N for count:1..N       is the array at index N greater than X?              true: assign X the value of the array element                      assign Y the value of 'count' %which score is the highest              false, restart the loop to check the next array element end for %now at this point, you've gone through the array, and X should be your largest score, and Y should be the element number that the highest score was assigned to in the array output X set the array element Y to 0 %that way when it rechecks the array, it won't re-choose that biggest element again since when it checks to see if X is greater than it, it will read 0 Now it restarts the whole process over again... this will happen N times end for

I hope you understand that
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: