programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Liutauras Vilda
• Tim Cooke
• Jeanne Boyarsky
• Paul Clapham
Sheriffs:
• Devaka Cooray
• Ron McLeod
• paul wheaton
Saloon Keepers:
• Tim Moores
• Piet Souris
• Tim Holloway
• Stephan van Hulst
• Carey Brown
Bartenders:
• Al Hobbs
• Frits Walraven
• Scott Selikoff

# Binary Search Tree that prints values

Ranch Hand
Posts: 63
• Number of slices to send:
Optional 'thank-you' note:
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:

Cross post link here Binary Search Tree that prints values

Bartender
Posts: 10780
71
• Number of slices to send:
Optional 'thank-you' note:

Aron Silvester wrote: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.

Well, first you probably need a method that can traverse the keys of your tree in reverse order. Have you tried that yet?

Winston

Ranch Hand
Posts: 954
4
• Number of slices to send:
Optional 'thank-you' note:
Hi Aron, what is your thought on this?

Ranch Hand
Posts: 48
• Number of slices to send:
Optional 'thank-you' note:
You can try using the natural order in the collections framework or use array and iteration to achieve this. Depending on the list you have, just reversing it might not sort it from the highest to the lowest. You might want to swap the positions. Moving the lowest to the back and bring the highest in front. Which is a binary sort algorithm.

 No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad: the value of filler advertising in 2021 https://coderanch.com/t/730886/filler-advertising