Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 1249. first step for Huffman Coding (easy)

Created by Tanguy

Given a string, you must sort the characters by occurrence (from lowest to highest).

This step is necessary to generate a Huffman tree. ( http://en.wikipedia.org/wiki/Huffman_coding )

All characters must be taken into account. Capitals are not taken into account.

If two characters appear the same number of times, the order does not matter.

You will return two arrays:

the first comprising the characters sorted. the second comprising the number of occurrence of characters of the first array.

Example :

input :

    input = 'aAabbC';

output :

characters :

cha =
c
b
a

occurence :

occ =
       1
       2
       3

Tags

Problem Group

Solution Statistics

36 correct solutions 38 incorrect solutions
Last solution submitted on Jul 15, 2014