Thread: can someone please explain this struct to me???

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    11

    can someone please explain this struct to me???

    hey ppl... ive got this struct as a starting point to write a program for a binary search tree program... im not really sure what all the lines mean, particularly the pointers can someone please explain what each line does

    thanks

    Code:
    typedef struct record 
    { 
    
    	char key[30]; 
    	int count; 
    
    }DATA; // 
    
    
    typedef struct treenode 
    { 
    
    	DATA *word; 
    	struct treenode *left; 
    	struct treenode *right; 
    
    }TREENODE, *TREEPTR; 
    
    
    TREEPTR root; 
    DATA *new_word;

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Essentially each node contains pointer to the data and two pointers to the left and right node. That is the foundation of a binary tree.

    Kuphryn

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    See the FAQ for a detailed explanation of binary search trees. The only potentially confusing part I can see is the use of a pointer so that a structure can have a member of its own type. Can you be more specific about what parts of the code you don't understand and why?
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating in linked list
    By drater in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 11:10 PM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. problem with structures and linked list
    By Gkitty in forum C Programming
    Replies: 6
    Last Post: 12-12-2002, 06:40 PM
  5. what does this mean to you?
    By pkananen in forum C++ Programming
    Replies: 8
    Last Post: 02-04-2002, 03:58 PM