PreOrder,InOrder,PostOrder traversal using Iterations
//inOrder traversal.... public List < Integer > inorderTraversal ( TreeNode root ) { List < Integer > ans = new ArrayList < Integer > ( ) ; Stack < TreeNode > st = new Stack < > ( ) ; if ( root == null ) return ans ; TreeNode node = root ; while ( true ) { if ( node != null ) { st . push ( node ) ; node = node . left ; } else { if ( st . isEmpty ( ) ) break ; node = st . pop ( ) ; ans . add ( node . val ) ; node = node . right ; } } return ans ; //preOrder traversal below.. public List < Integer > preorderTraversal ( TreeNode root ) { List < Integer > ans = new ArrayList <>(); if (root== null ) ...