|
-
May 2nd, 2008, 12:56 PM
#1
Thread Starter
New Member
selection sort program
just wondering if anyone knew of any selection sort programs. i am looking for one that will open a text file and when i click a button it will sort the names within the text file in alphabetical order...i would really appreciate someone else. Thanks
-
May 2nd, 2008, 12:58 PM
#2
Re: selection sort program
-
May 2nd, 2008, 12:59 PM
#3
Re: selection sort program
Sounds like homework of some sort. Have you tried writing a selection sort algorithm yourself?
-
May 2nd, 2008, 01:15 PM
#4
Re: selection sort program
Why selection sort?
You are going to have to read all the lines from the text file, sort them, then write them all back out. If the file is just a list of names, with one name per line, then this is a really simple task....until you decide to use some kind of custom sorting algorithm. That step alone will increase the level of difficulty from about three lines to many.
In any case, you will be sorting an array of strings, so if you have to make your own sorting routine, make one that sorts arrays of strings.
My usual boring signature: Nothing
 
-
May 2nd, 2008, 01:17 PM
#5
Re: selection sort program
Read here. You can even find sample code (written in C++ though)
http://www.codecodex.com/wiki/index....Selection_sort
-
May 2nd, 2008, 01:18 PM
#6
Re: selection sort program
 Originally Posted by Shaggy Hiker
Why selection sort?
Because it's a homework assignment and the teacher specifies to use selection sort....
-
May 2nd, 2008, 01:21 PM
#7
Re: selection sort program
That's what most questions are, but I thought I'd lead off with a question.
I've wondered about these homework assignments before, and I will wonder about them again. I can understand the idea that you teach someone how a sort routine works, but why choose one over any other? I guess I can understand why Shell sort and qSort aren't taught, since they are nearly impossible to understand, but why selection sort?
My usual boring signature: Nothing
 
-
May 2nd, 2008, 03:40 PM
#8
Re: selection sort program
http://en.wikipedia.org/wiki/Selection_sort
Take a shot at it and then post your code if you need help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|