Solution

ID: past-exam-of-the-mathematics-course-of-the-university-of-cambridge/2025/iii/paper-224/4/c/i/solution

For any fixed threshold , minimizing the excess-length probability means assigning the available strings shorter than to the most probable symbols. Repeating this exchange argument simultaneously for every threshold orders symbols by decreasing probability and assigns binary strings from shortest to longest. There are words of length , so the th word in shortlex order has length
This is the optimal one-to-one binary code.

New to topics? Read the docs here!