Use the queue data structure for level order insertion and push the root of tree to Queue
Queue < node > Q = new LinkedList < node > ( ) ; Q . add ( root ) ; while ( ! Q . isEmpty ( ) ) { node temp = Q . peek ( ) ; Q . remove ( ) ;