Skip to content

Encode the alphabet as a binary tree using the frequencies of letters in the given text

Notifications You must be signed in to change notification settings

jakubdura/java-task-binary-tree

Repository files navigation

Java task binary tree

Task: Encode the alphabet as a binary tree using the frequencies of letters in the given text.

  • For each character in the text calculate its number of occurrences.
    eg. for string acdc it would be [a -> 1], [c -> 2], [d -> 1]
  • For each character and its frequency create a one-node tree.
  • Take two trees T1 and T2 with the lowest frequencies and merge them into a larger tree T12
    (T1 should become the left sub-tree and T2 the right subtree).
  • Repeat the previous step until there is only 1 tree left.

That last tree represents the created encoding. For example, given text ababacccccc you should get:

This is an image

About

Encode the alphabet as a binary tree using the frequencies of letters in the given text

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages