Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Tree balance error

 
Ranch Hand
Posts: 1329
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to get a binary search tree to balance, and I know why it's not working, but I don't know how to fix it.
I balance directly in the insert method.
I put some slash to note where the balancing should happen.
Like this the code is not working:

 
Marshal
Posts: 64666
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start with some rubber duck programming. Explain to us in small simple words what the algorithm for balancing the tree is. Then explain what algorithm you are using and where you think the error os.

That may enable you to see the solution without our help.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!