Print the right most element of every subtree in a binary tree data structure.
Anonymous
func printOnlyRightElements(tree : BinaryTree) { if let rightTree = tree.rightNode { print(rightTree.value) printOnlyRightElements(tree: rightTree) } if let leftTree = tree.leftNode { printOnlyRightElements(tree: leftTree) } } printOnlyRightElements(tree: leaf2)
Check out your Company Bowl for anonymous work chats.