Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using Binary Search Trees to implements "Sets of characters"  RSS feed

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok in the following two methods...



I didn't think any more code was neccesary to fix this problem,
and seeing as my code is super long, i wanted to get to the point
as good and with as little code as possible,(less code faster answers).

but the logic seems ok, and when i debug the curr.item in "TreetoArray()"
it prints out the curr of both the BSTChar one and two.

in the main i put in... "LUCKYU" and "VLMPUC"..

and tried to find the Intersection of those two...

but in the Intersection() method, when i try to debug the for loops that look for alike terms, it prints nothing...

and when i say debuging, i just mean using System.out

thanks,
Justin

p.s,
please hurry,
time is precious!

thanks again.
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand your exact intent, but perhaps it might be worth it to re-check the TreeToArray() method ?
It looks like data is overridden instead of being accumulated into the array... for example, the effect of TreeToArray(curr.left, array) seems to be completed overridden when you do array[i]=curr, because i=0 (note the "i" variable is local to the method, so the effect of "i++" is not accumulated through the recursion)...

Have you tried debugging just this method ?

Good luck
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!