Your indentation is quite inconsistent. Consider adopting an indentation style and sticking with it, it will make your code more readable so you'll be able to spot bugs faster, and other people will be more willing to read it....
Anyway. Code like this
Code:
int compressed_array[length][2];
for (i=0;i<=length;i++){
compressed_array[i][0] = org_array[i][0];
compressed_array[i][1] = org_array[i][1];
}
causes a buffer overrun since the valid indices of compressed_array[i] are 0 through length-1. You should use the for(i=0;i<length;i++) idiom. It's even worse when, lower down, you have an off-by-two error!
Code:
for(i = 0; i <=length+1; i++){
That's going two elements too far.
Another minor point: when you open a file the file pointer will be at the beginning of the file. There's no need to fseek(fp, 0, SEEK_SET) unless you've read some data from the file.
If I fix these buffer overruns through the hacky method of making enough space in the arrays rather than fixing your loops,
Code:
$ diff utility.c.orig utility.c
59c59
< int compressed_array[length][2];
---
> int compressed_array[length+2][2];
83c83
< LEAF *array[length] ;
---
> LEAF *array[length+2] ;
then when I run the program I no longer get a segmentation fault but rather an infinite loop from the PostOrderWalk function. In other words, you've probably managed to construct a cycle in your tree. I didn't look into it any more closely than that but maybe this will get you started.