Java Solution | Simple BFS Traversal | Very easy iterative solution
\nclass Solution {\n\n    public Node connect(Node root) {\n        if (root == null) return root;\n        Queue<Node> q = new LinkedList<>();\n        q.add(r
```\nclass Solution {\n\n    public Node connect(Node root) {\n        if (root == null) return root;\n        Queue<Node> q = new LinkedList<>();\n        q.add(root);\n        while (!q.isEmpty()) {\n            int size = q.size();\n            for (int i = 0; i < size; i++) {\n                Node curr = q.poll();\n                if (curr.left != null) q.add(curr.left);\n                if (curr.right != null) q.add(curr.right);\n                if (i == size - 1) curr.next = null; else curr.next = q.peek();\n            }\n        }\n        return root;\n    }\n}\n```
['Breadth-First Search', 'Queue', 'Java']