Remove vowels from a string stored in a Binary Tree | Structure Representing the Node in the Binary tree ; Function to perform a level order insertion of a new Node in the Binary tree ; If the root is empty , make it point to the new Node ; In case there are elements in the Binary tree , perform a level order traversal using a Queue ; If the left child does not exist , insert the new Node as the left child ; In case the right child does not exist , insert the new Node as the right child ; Function to print the level order traversal of the Binary tree ; Function to check if the character is a vowel or not . ; Function to remove the vowels in the new Binary tree ; Declaring the root of the new tree ; If the given character is not a vowel , push it to the new Binary tree ; Driver code
class Node { constructor ( _val ) { this . data = _val ; this . left = null ; this . right = null ; } } ; function addinBT ( root , data ) { if ( root == null ) { root = new Node ( data ) ; } else { var Q = [ ] ; Q . push ( root ) ; while ( Q . length != 0 ) { var temp = Q [ 0 ] ; Q . shift ( ) ; if ( temp . left == null ) { temp . left = new Node ( data ) ; break ; } else Q . push ( temp . left ) ; if ( temp . right == null ) { temp . right = new Node ( data ) ; break ; } else Q . push ( temp . right ) ; } } return root ; } function print ( root ) { var Q = [ ] Q . push ( root ) ; while ( Q . length > 0 ) { var temp = Q [ 0 ] ; Q . shift ( ) ; document . write ( temp . data ) ; if ( temp . left != null ) Q . push ( temp . left ) ; if ( temp . right != null ) Q . push ( temp . right ) ; } } function checkvowel ( ch ) { ch = ch . toLowerCase ( ) ; if ( ch == " " ch == " " ch == " " ch == " " ch == " " ) { return true ; } else { return false ; } } function removevowels ( root ) { var Q = [ ] Q . push ( root ) ; var root1 = null ; while ( Q . length != 0 ) { var temp = Q [ 0 ] ; Q . shift ( ) ; if ( ! checkvowel ( temp . data ) ) { root1 = addinBT ( root1 , temp . data ) ; } if ( temp . left != null ) { Q . push ( temp . left ) ; } if ( temp . right != null ) { Q . push ( temp . right ) ; } } return root1 ; } var s = " " ; var root = null ; for ( var i = 0 ; i < s . length ; i ++ ) { root = addinBT ( root , s [ i ] ) ; } root = removevowels ( root ) ; print ( root ) ;