Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Height of a node in a binary tree

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Height of a node in a binary tree

    Hello,

    I have a question regarding the height of a node in a binary tree other than the root node? In my height method, for the root i can pass the root as a parameter. But if i want to find the height of a node other than the root , what shud i pass as a parameter in that function?? Would really appreciate your help!!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Height of a node in a binary tree

    Why not the node itself? I presume the nodes in the tree have references to their parent.

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    24
    My Mood
    Fine
    Thanks
    5
    Thanked 3 Times in 3 Posts

    Default Re: Height of a node in a binary tree

    Good start, so far!

    What you need:
    - the height of a node

    What you have:
    - passing in the root as parameter

    What you are missing:
    ... because it is a recursive method, in each method call, you need to keep track of the CURRENT height somehow, right? So... what are you missing??

Similar Threads

  1. [SOLVED] Finding deepest node of tree??
    By bczm8703 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 10th, 2011, 12:48 PM
  2. Java Binary Tree
    By comwizzz in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 28th, 2011, 03:15 PM
  3. need help with binary tree
    By vash0047 in forum Java Theory & Questions
    Replies: 5
    Last Post: July 12th, 2010, 09:23 AM
  4. Data Structures(Binary Search Tree to AVL Tree)ASAP
    By jfAdik in forum Algorithms & Recursion
    Replies: 2
    Last Post: April 5th, 2010, 04:58 AM
  5. Problem with binary tree
    By Exoskeletor in forum Object Oriented Programming
    Replies: 2
    Last Post: January 8th, 2010, 01:03 PM