April 2017
Intermediate to advanced
316 pages
9h 33m
English
To make this BST a little more complete, let's implement a property to check for its size:
var size: Int { switch self { case .leaf: return 0 case .node(let lhs, _, let rhs): return 1 + lhs.size + rhs.size } }
This computed property is going to provide the size of the BST, and we can use it as follows:
print(functionalBST.size) // prints "3"
Read now
Unlock full access