Help with Shannon-Fano Coding

Back to Problem Solutions forum

b_pritom     2016-02-23 08:18:12

Hi, I am keep getting wrong answers for this problem. The code looks correct to me, so I must be missing something!

Here is an example:

Expected

32 OOO 101 OOI 116 OIOO 97 OIOI 105 OIIO 104 OIII 110 IOOO 111 IOOIO 115 IOOII 100 IOIO 114 IOIIO 109 IOIII 117 IIOOO 119 

IIOOI 108 IIOIO 121 IIOIIO 34 IIOIII 73 IIIOOO 46 IIIOOI 99 IIIOIO 107 IIIOIIO 44 IIIOIII 98 IIIIOOO 112 IIIIOOI 65 IIIIOIO 

102 IIIIOII 103 IIIIIOO 63 IIIIIOIO 72 IIIIIOII 80 IIIIIIOO 83 IIIIIIOI 84 IIIIIIIO 106 IIIIIIIIO 118 IIIIIIIII


Mine

32 OO 101 OIO 116 OIIO 97 OIIIO 105 OIIII 104 IOOO 110 IOOI 111 IOIO 115 IOIIO 100 IOIIIO 114 IOIIII 109 IIOO 117 IIOIO 119 

IIOIIO 108 IIOIII 121 IIIOO 34 IIIOIO 73 IIIOIIO 46 IIIOIII 99 IIIIOO 107 IIIIOIO 44 IIIIOIIO 98 IIIIOIII 112 IIIIIOO 65 

IIIIIOIO 102 IIIIIOII 103 IIIIIIOO 63 IIIIIIOIO 72 IIIIIIOII 80 IIIIIIIOO 83 IIIIIIIOI 84 IIIIIIIIO 106 IIIIIIIIIO 118 

IIIIIIIIII


Input

"I am immensely indebted to you. Pray tell me in what way I can "And how did you find out?" "It is most unlikely that she 

carries it about with her. It is to Holmes to draw back now from the part which he had intrusted "I do not wish to make a 

mystery," said he, laughing. "The matter Serpentine Avenue. It was already dusk, and the lamps were just

C++ source is here C# source is here

Code is a bit messed up because I am trying to debug it. Didn't paste them directly as they are long (150+ lines)

Any advice? thanks!

b_pritom     2016-02-24 10:49:56

Never mind, I have solved it! the way I was calculating the position to split was incorrect. It's working fine now :)

Please login and solve 5 problems to be able to post at forum