Thread: would you help me with Linked list, please?

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    18

    Lightbulb would you help me with Linked list, please?

    I have some questions about Linked list. I understand the basic
    concepts but need some help putting thoughts together, please.
    The program should read info from the file which contains words and meaning
    such as :
    eat meaning1
    go meaning2

    It is a dictionary program which should be able to lookup the word and find
    the meaning. My data structure is defined as below:

    typdedef struct DTNtag
    { char data;
    char* meaning;
    struct DTNtag* otherLetter;
    struct DTNtag* nextLevel;
    } DictonaryTreeNode, *DictionaryTreeNodePtr;

    We are not inserting a key and a value. Each node in my tree is
    associated with a letter (and a possible meaning). Given a pointer to
    a DTNode, I should be able to navigate thru the tree by looking at
    the otherLetter field and the nextLevel field until you reach a
    meaning (the meaning field). For example,

    nodePtr
    |
    v
    ----- -----
    |'a'| | 'i' |
    | 1 | | 2 |
    | ---->| 0 |
    | | | | | |
    --|-- --|--
    | |
    v v
    ----- -----
    |'n' | | 't' |
    | 3 | | 4 |
    | 0 | | 0 |
    | | | | 0 |
    --|-- -----
    |
    v
    -----
    | 't' |
    | 5 |
    | 0 |
    | 0 |
    -----

    1 -> "meaning for "a""
    2 -> "meaning for "i""
    3 -> "meaning for "an""
    4 -> "meaning for "it""
    5 -> "meaning for "ant""

    These five nodes represent five words in our dictionary: "a", "an",
    "ant", "i", "it".

    Let's assume our user wants to add the word "and" to the dictionary.
    After the call to addWord() our tree would look like this:

    nodePtr
    |
    v
    ----- -----
    |'a' | |'i' |
    | 1 | | 2 |
    | ------>| 0 |
    | | | | | |
    --|-- --|--
    | |
    v v
    ----- -----
    |'n' | |'t' |
    | 3 | | 4 |
    | 0 | | 0 |
    | | | | 0 |
    --|-- -----
    |
    v
    ----- -----
    |'d' | |'t' |
    | 6 | | 5 |
    | 0 | | 0 |
    | 0 | | 0 |
    ----- -----

    With 6 -> "meaning of "and""

    Would you be able to help me with the following
    functions? It's for read the file and search the word which has meaning. The meaning is also from the file.

    DictionaryTreeNodePtr read(char* fileName);
    char* lookup(DictionaryTreeNodePtr root, char* word);

    thank you very much.
    Last edited by unhwan; 06-11-2002 at 12:24 AM.

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Search the forums with the keyword: "Linked List", you'll get a lot of information on the same.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM