Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2018/imperative-programming/5/a/solution

Each binary tree entry stores its word, positive frequency, and two child references:
class Tree(val word: String, var count: Int,
           var left: Tree = null, var right: Tree = null)
A null reference denotes an empty subtree. A word is a non-null string data type value; its order below is the fixed lexicographic order used by String.compareTo.

New to topics? Read the docs here!