You are given a string s consisting of alphabetic characters ('A'-'Z', 'a'-'z). Build a binary tree that represents the frequency distribution of characters in s under the following conditions:
- Leaf Nodes:
- Each distinct character in
smust appear exactly once as a leaf node. - A leaf node contains:
ch: the character itself.count: the number of times that character appears ins.
- Each distinct character in
- Internal Nodes:
- Every internal node must have:
chset to'#'.countequal to the sum of thecountvalues of all leaves in its subtree.
- Every internal node must have:
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Stdout
-