Algorithm · Square · Medium
You are given a string s containing only alphabetic characters (uppercase 'A'-'Z' and lowercase 'a'-'z'). Your task is to construct a binary tree that captures the frequency distribution of the characters in s according to the rules below. Node Structure You must use the following class definition: java class TreeNode { char ch; int count; TreeNode left; TreeNode right; } Leaf nodes: Each distinct character that appears in s must occur exactly once as a leaf. A leaf stores:…
Checking your access…