|
-
Oct 22nd, 2001, 06:06 PM
#1
Linked list
Im trying to make a program in c++ that will take some files, grab each word individualy, get rid of any doubles, sort the words from a-z and write each word to the console. I have no idea how to go about doing this. Would linked list's do this? Im asking because i would have to learn them, and i dont want to learn them yet if there not gonna help.
-
Oct 22nd, 2001, 06:53 PM
#2
transcendental analytic
Linked list are optional, I'd suggest other datastructures for faster sorting but they are more complicated, but in actuallity very easy to understand.
How many words to sort (about) and would you like it to go as fast as possible?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 22nd, 2001, 07:47 PM
#3
Thats just it. It could be 2 words, or it could be 50,000. I heard linked list can grow as needed, thats why they came to mind first.
-
Oct 22nd, 2001, 08:14 PM
#4
C++ supports dynamic arrays in that you can expand the array any time you need.
Linked lists are structs that point forward and backward to the next/previous struct. It's like a list of records that know their immediate nextdoor neighbors, but nobody else.
Code:
struct LL {
struct LL *backward;
char data[20];
struct LL *forward
};
What you want is an array. Since I just posted the algorithm for removing duplicates, I gonna be lazy and tell you to go here:
IT's for an array of chars, but the logic is the same - compare with strcmp() which returns 0 if the two are equal.
http://www.vbforums.com./showthread....hreadid=107643
-
Oct 22nd, 2001, 08:35 PM
#5
transcendental analytic
That'd be arrays of C-strings then. Quicksort, Shellsort, Mergesort, Bucketsort, Heapsort, Radixsort, what would you like?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|