The idea is similar to a level-order traversal and remember to take full advantages of the prefect binary tree assumption in the problem statement.

The code (iterative solution) is as follows.

```
class Solution {
public:
void connect(TreeLinkNode *root) {
TreeLinkNode* pre = root;
TreeLinkNode* cur = NULL;
while (pre) {
cur = pre;
while (cur && cur -> left) {
cur -> left -> next = cur -> right;
if (cur -> next)
cur -> right -> next = cur -> next -> left;
cur = cur -> next;
}
pre = pre -> left;
}
}
};
```

This problem can also be solved recursively.

```
class Solution {
public:
void connect(TreeLinkNode *root) {
if (!root) return;
if (root -> left) {
root -> left -> next = root -> right;
if (root -> next)
root -> right -> next = root -> next -> left;
}
connect(root -> left);
connect(root -> right);
}
};
```