i want to obtain the binary code of all the leafes of a bin tree. have any ideea on how to do that?
i code 0 for left and 1 of right.
Thank you!
i want to obtain the binary code of all the leafes of a bin tree. have any ideea on how to do that?
i code 0 for left and 1 of right.
Thank you!
00111010111011101010010101010010101001010010101010 10101000110011101001010101001010100101010101001010 10100101110101010101010100100101010101010101010010 10101001010110101101101011011101010001001010101010 10110101010101010101010111101010111100101010101010 10110000101000010100101111101011010101000010101011 11101011110100010110101010101011101011011101101100 10110110100001001011110110100101010100100110111010 10101101010
Quzah.
Hope is the first step on the road to disappointment.
thank you. but i was thinking more of an algorithm on how to code that!
please... any ideea? i'm trying to implement huffman algorithm!
solved it... i can do a preorder tranversal:
Code:void preordine(tree a,char bin[100]) { char s[100],d[100]; if((a->leg[0]==NULL)&&(a->leg[1]==NULL)) { printf("%lf\n",a->prob); puts(bin); } else { strcpy(s,bin); strcpy(d,bin); strcat(s,"0"); strcat(d,"1"); preordine(a->leg[0],s); preordine(a->leg[1],d); } }