Results 1 to 2 of 2
  1. #1
    asilvester635 is offline Member
    Join Date
    Dec 2015
    Rep Power

    Default Binary Search Tree that prints values

    How do you write a method that prints the contents of a tree from highest to lowest. Ex. 15, 13, 10, 8, 7, 3, 1.

    My Node Class:

    Java Code:
    class node {
    	   node left;
    	   node right;
    	   int data; }
    Cross post link here Binary Search Tree that prints values (Beginning Java forum at JavaRanch)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Binary Search Tree that prints values

    Assuming that the tree is sorted, you need to do an in-order traversal. That means traversing either the left or right node, visiting the root, and then traversing the other node. You should probably read about tree traversal on the web. Wikipedia probably has some good info.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 12
    Last Post: 11-26-2014, 12:05 AM
  2. Replies: 0
    Last Post: 04-04-2010, 08:40 AM
  3. Binary search tree search method
    By chopo1980 in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 02:42 AM
  4. Binary Search Tree
    By anmadie in forum New To Java
    Replies: 5
    Last Post: 11-17-2009, 03:39 AM
  5. Binary Search Tree
    By michael_mke in forum New To Java
    Replies: 3
    Last Post: 12-04-2008, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts