Results 1 to 5 of 5

Thread: Linked list

  1. #1
    ChimpFace9000
    Guest

    Post 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.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3
    ChimpFace9000
    Guest
    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.

  4. #4
    jim mcnamara
    Guest
    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

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
  •  



Click Here to Expand Forum to Full Width