Threaded Binary Tree | Utility function to find leftmost node in a tree rooted with n ; C code to do inorder traversal in a threaded binary tree ; If this node is a thread node , then go to inorder successor ; Else go to the leftmost child in right ; subtree
Node leftMost ( Node n ) { if ( n == null ) return null ; while ( n . left != null ) n = n . left ; return n ; } static void inOrder ( Node root ) { Node cur = leftMost ( root ) ; while ( cur != null ) { System . out . printf ( " % d ▁ " , cur . data ) ; if ( cur . rightThread ) cur = cur . right ; else cur = leftmost ( cur . right ) ; } }