Driver code
public static void main ( String [ ] args ) { new TrieNode ( ) ; TrieNode root = getNode ( ) ; String dictionary [ ] = { " sam " , " sung " , " samsung " } ; int n = dictionary . length ; for ( int i = 0 ; i < n ; i ++ ) { insert ( root , dictionary [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( dictionary [ i ] + ": NEW_LINE"); wordBreakAll ( root , dictionary [ i ] , dictionary [ i ] . length ( ) , " " ) ; } } }