Hey fellas,
I have a subsequent question. I have re-implemented my struct node as such:
Code:
typedef struct node {
int code;
int prefix;
char ch;
node** child
} node;
I only want to store the child pointers that aren't null, so when I create a node, I have the code:
Code:
node->child = malloc(sizeof(node**));
and when I'm inserting nodes, I just do child[0] = node1, child[1] = node2, ..
However, I don't think that's the correct way to do it. I get a corrupt heap error, which means I'm overwriting memory that I've already allocated. So, I wanted some conceptual help here. How should I go about only storing the children that aren't null? I basically want memory efficiency.
I'm updating the OP with this.