Tree: Height of a Binary Tree

  • + 0 comments

    Swift version seems to be broken and crashes for any tree with more than one node due to an error in reading the input here:

    let t = Int(readLine()!)!

    for _ in 0..

    root = tree.insert(root: root, data: Int(readLine()!)!)
    

    }

    The problem is that the 'for' loop expects for each node data to appear on a separate line, while they all on the same line separated by commas.