Check whether a binary tree is a full binary tree or not | Tree node structure ; this function checks if a binary tree is full or not ; if empty tree ; if leaf node ; if both left and right subtrees are not null the are full ; if none work ; Driver program
class Node { constructor ( item ) { this . data = item ; this . left = this . right = null ; } } var root ; function isFullTree ( node ) { if ( node == null ) return true ; if ( node . left == null && node . right == null ) return true ; if ( ( node . left != null ) && ( node . right != null ) ) return ( isFullTree ( node . left ) && isFullTree ( node . right ) ) ; return false ; } root = new Node ( 10 ) ; root . left = new Node ( 20 ) ; root . right = new Node ( 30 ) ; root . left . right = new Node ( 40 ) ; root . left . left = new Node ( 50 ) ; root . right . left = new Node ( 60 ) ; root . left . left . left = new Node ( 80 ) ; root . right . right = new Node ( 70 ) ; root . left . left . right = new Node ( 90 ) ; root . left . right . left = new Node ( 80 ) ; root . left . right . right = new Node ( 90 ) ; root . right . left . left = new Node ( 80 ) ; root . right . left . right = new Node ( 90 ) ; root . right . right . left = new Node ( 80 ) ; root . right . right . right = new Node ( 90 ) ; if ( isFullTree ( root ) ) document . write ( " " ) ; else document . write ( " " ) ;