Package Level3; import Utility. treeLinkNode;/*** Populating Next Right Pointers in Each Node *** Given a binary tree struct TreeLinkNode {TreeLinkNode * left; TreeLinkNode * right; TreeLinkNode * next ;} populate each next pointer to point to its next right node. if there is no next right node, the next pointer shoshould be set to NULL. initially, all next pointers are set to NULL. note: You may only use co Nstant extra space. you may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children ). for example, Given the following perfect binary tree, 1/\ 2 3 // \/\ 4 5 6 7 After calling your function, the tree shoshould look like: 1-> NULL/\ 2-> 3-> NULL/\ 4-> 5-> 6-> 7-> NULL **/public class S116 {public static void main (String [] args) {} publi C static void connect (TreeLinkNode root) {// if (root = null) {return ;}// the left node is not empty, connect to the right node if (root. left! = Null) {root. left. next = root. right;} // you can use root. next to process the scenario of 6-to-6 connections. if (root. right! = Null & root. next! = Null) {root. right. next = root. next. left;} connect (root. left); connect (root. right );}}