Thread: Binary tree problem that i cannot solve :(

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    1

    Binary tree problem that i cannot solve :(

    Hello,

    I made a simple binary tree.
    Code:
    have a structure NODE 
    typedef struct node {
      char name[MAX];
      char surname[MAX];
      int counting;
      struct node *l, *r;
    } NODE;
    I have function,that make new nodes and insert nodes in to the tree.........
    For example i will put this in my tree.
    John Smith
    Adam Smith
    Mike Johnson
    Peter Thomas
    Steven Thomas

    I do not know how to write function,that will PRINT surnames only once,and will print number of appearance of surnames.

    PRINT RESULT will be like this :
    Smith 2
    Johnson 1
    Thomas 2

    Does anyone know how to write this function,that will print surnames only once ?

    Thanks in advantage!

  2. #2
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by sava View Post
    Does anyone know how to write this function,that will print surnames only once ?

    Thanks in advantage!
    I am sure there are many people here that know how to do it. What have you tried so far? Take a look at Preludes Binary Search Tree tutorial, that should give you a good starting point for this project.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #3
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by sava View Post
    I do not know how to write function,that will PRINT surnames only once,and will print number of appearance of surnames.

    PRINT RESULT will be like this :
    Smith 2
    Johnson 1
    Thomas 2

    Does anyone know how to write this function,that will print surnames only once ?

    Thanks in advantage!
    Look up strcmp() and stricmp() in your C Library Documentation ... that should give you a pretty good hint how to do it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary tree problem
    By moddinati in forum C++ Programming
    Replies: 8
    Last Post: 06-19-2008, 05:05 PM
  2. Binary Tree Problem
    By noodle24 in forum C++ Programming
    Replies: 2
    Last Post: 04-16-2007, 02:20 PM
  3. binary tree problem
    By spank in forum C Programming
    Replies: 4
    Last Post: 04-24-2006, 05:27 AM
  4. Binary tree problem
    By carrja99 in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 09:36 PM
  5. binary tree problem??
    By fergie in forum C++ Programming
    Replies: 1
    Last Post: 04-23-2002, 12:17 PM