Thread: recursion in binary trees problem newbie

  1. #1
    totalfreeloader
    Guest

    recursion in binary trees problem newbie

    hi, im not sure what the output is in this piece of code
    for the following linked list

    [22]->[3]->[10]->[95]->[64]->[35]->[14]

    ////////////////////////////////////////////////////

    typedef struct Node * Nodeptr;
    struct Node {
    int data;
    Nodeptr Next;
    };

    void Process (Nodeptr X)
    {
    if(X != NULL) {
    Process(X -> Next);
    if( X -> Data % 5 == 0) {
    cout<< X-> Data <<endl;
    }
    }
    }

    ///////////////////////////////////////////////////////
    much appreciated

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Looks like it should be:
    35
    95
    10
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    totalfreeloader
    Guest
    thanx very much, thats what i thought,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Search Tree-Strange problem
    By lydiab in forum C Programming
    Replies: 12
    Last Post: 05-13-2009, 07:39 AM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Problem with Binary File I/O
    By DirX in forum C++ Programming
    Replies: 4
    Last Post: 03-01-2004, 09:34 AM
  4. Binary trees search problem...
    By Umoniel in forum C Programming
    Replies: 2
    Last Post: 02-22-2004, 02:29 PM
  5. Newbie questions regarding binary search trees
    By Ham in forum C++ Programming
    Replies: 1
    Last Post: 11-04-2001, 07:48 AM