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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about binary tree delete method (non-API; hand-coded)

 
Gunslinger
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I've got something that's been bugging me. For this binary tree deleteNode function, when a node is found, the method deleteFromTree is called on it. I understand everything, except: this may sound silly, but it seems that the method passes the target node on in a roundabout way. As you see, when found == true, we don't simply pass current as the method parameter, but rather tempCurrent.lLink or tempCurrent.rLink. Why is this? I know that there must be a reason that I'm not seeing (my text surely doesn't do it just for the heck of it), but it seems that this wastes computing time creating a reference to tempCurrent, then comparing it to deleteItem, then passing the appropriate child of tempCurrent to the deleteFromTree method, when current could simply be sent as the parameter, as it is the target node upon found == true. Thanks in advance!





deleteFromTree method:

 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Lets continue in the other thread
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic