# TreeSelect ## Data Structure ```go type TreeNode sturct { childs TreeNode[] parent TreeNode checked bool } ``` ## Algorithm ### Case 1: Select ```go func RecursiveUpSelect(node TreeNode) TreeNode{ if node == root return parent = node.parent if isFull(parent){ return RecursiveUpSelect(parent) }else{ return node } } func isFull(node TreeNode) bool{ for child in range node.childs { if !child.checked{ return false } } return true } ``` ### Case 2: Unselect ```go func Unselect(node TreeNode){ if node == root return [] parent := node.parent return parent.childs } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up