solution to connect (non-complete tree)