FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

jakubdura/java-task-binary-tree: Encode the alphabet as a binary tree using the frequencies of letters in the given text · GitHub

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:

About

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

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages


Back | FazBrowse Home | New Git URL