go (golang): DFS & BFS
DFS\ngolang\n/**\n * Definition for a Node.\n * type Node struct {\n *     Val int\n *     Left *Node\n *     Right *Node\n *     Next *Node\n * }\n */\n\nfunc 
1. DFS\n```golang\n/**\n * Definition for a Node.\n * type Node struct {\n *     Val int\n *     Left *Node\n *     Right *Node\n *     Next *Node\n * }\n */\n\nfunc connect(root *Node) *Node {\n    if root == nil {\n        return nil\n    }\n    \n    if root.Left != nil {\n        root.Left.Next = root.Right\n        \n        if root.Next != nil {\n            root.Right.Next = root.Next.Left\n        }\n    }\n    \n    connect(root.Left)\n    connect(root.Right)\n    \n    return root\n}\n```\n2. BFS\n```golang\n/**\n * Definition for a Node.\n * type Node struct {\n *     Val int\n *     Left *Node\n *     Right *Node\n *     Next *Node\n * }\n */\n\nfunc connect(root *Node) *Node {\n    if root == nil {\n        return nil\n    }\n    \n    q := []*Node{ root }\n    \n    for len(q) > 0 {\n        var pre *Node\n        \n        for _, n := range q {\n            q = q[1:]\n            \n            if pre != nil {\n                pre.Next = n\n            }\n            \n            pre = n\n            \n            if n.Left != nil {\n                q = append(q, n.Left)\n            }\n            \n            if n.Right != nil {\n                q = append(q, n.Right)\n            }\n        }\n    }\n    \n    return root\n}\n```
[]