For printing nodes from right to left , push the nodes to stack instead of printing them .
else { if ( temp -> right ) Q . push ( temp -> right ) ; if ( temp -> left ) Q . push ( temp -> left ) ; } } cout << endl ;