Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Linked list help!

  1. Apr 9, 2006 #1
    I have two problems:
    please can someone give me an algorithm that would help me to understand how to put words ( read from a file) in alphabetical order using a linked list. I just dont get it!!

    Also, The words that I need to input is a real text.
    but There is punctuation (",", "!",".") that I need to skip in order to continue inputting words.
    I know that I can do
    Code (Text):
     fscanf(fptr,"  [^,], ", words)
    to skip the comma. but how can I do all the 3 punctuations in once?

    Thank you for your help
  2. jcsd
  3. Apr 9, 2006 #2


    User Avatar
    Staff Emeritus

    1) There are a lot of ways you can do this.

    a) You can read everything into a linked list and then sort
    b) You can use a bucket approach. Stick words in an appropriate bucket based on the first letter of the word, then sort each bucket and combine.
    c) You can use a tree approach. Same as bucket approach, but you can have a linked list of sub-buckets. You'll be sorting on the fly with this method. All you have to do at the end is combine.

    Which one do you want to do?

    2) Isn't it just:


    You're modifing the string to exlude ',', '!', and '.'
    Last edited: Apr 9, 2006
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Linked list help!
  1. Linked List (Replies: 9)

  2. Linked list (Replies: 12)

  3. Java linked list (Replies: 1)