recursion in C, need some help

This is a discussion on recursion in C, need some help within the C Programming forums, part of the General Programming Boards category; I want to create a recursion function that will allow me to do this: Say I have a string: Name: ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    569

    recursion in C, need some help

    I want to create a recursion function that will allow me to do this:

    Say I have a string:

    Name: John Micky

    and another String

    John : Sarah

    another String

    Micky : Hubert

    As we can see above because John is associated with Sarah I want to get to the string Sarah from John

    The same case for Micky, Micky has an association wih Hubert..

    so this is how I want it to be:

    I have an array that contains the value John and Micky

    I also have another array that has the value John and Sarah

    when I access to John I want to get to Sarah and after I found Sarah, i wan't to be able to backtrack and go to Micky and find the association with Micky..

    how do I do this?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Sounds like a graph. The strings would be your nodes and the connections your edges.

    Or if there's always one in-link and one out-link, a doubly-linked list.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    hmm..actually I have stored this in a hash table.. Name is the key, the value of the key is John and Micky

    John is the key Sarah is the value and also Micky is the key with Hubert as the value

    so for the example above there are three keys

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Maybe I'm misunderstanding, but John and Micky wasn't a relationship? Just a list to parse through. If all the relationships are one-way, then a hash-table should work.

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    569
    no John and Micky are different individuals

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Template Recursion Pickle
    By SevenThunders in forum C++ Programming
    Replies: 20
    Last Post: 02-05-2009, 08:45 PM
  2. Recursion... why?
    By swgh in forum C++ Programming
    Replies: 4
    Last Post: 06-09-2008, 09:37 AM
  3. a simple recursion question
    By tetra in forum C++ Programming
    Replies: 6
    Last Post: 10-27-2002, 09:56 AM
  4. To Recur(sion) or to Iterate?That is the question
    By jasrajva in forum C Programming
    Replies: 4
    Last Post: 11-07-2001, 08:24 AM
  5. selection sorting using going-down and going-up recursion
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-02-2001, 01:29 PM

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