Need algorithm to add Node in binary tree

Posted by m.qayyum on Stack Overflow See other posts from Stack Overflow or by m.qayyum
Published on 2010-04-26T01:01:34Z Indexed on 2010/04/26 1:03 UTC
Read the original article Hit count: 303

Filed under:
|
|

•if your new element is less or equal than the current node, you go to the left subtree, otherwise to the right subtree and continue traversing •if you arrived at a node, where you can not go any deeper, because there is no subtree, this is the place to insert your new element

           (5)Root 
  (3)-------^--------(7) 

(2)---^----(5) ^-----(8) (5)--^

i want to add this last node with data 5...but i can't figure it out...I need a algorithm to do that or in java language

© Stack Overflow or respective owner

Related posts about binary

Related posts about tree