would you help me with Linked list, please?

This is a discussion on would you help me with Linked list, please? within the C Programming forums, part of the General Programming Boards category; I have some questions about Linked list. I understand the basic concepts but need some help putting thoughts together, 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 01: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, 11:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 11: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, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21