Hello. Im new to Trie. I know it's concept but I can't declare and access it correctly. I tried making a code. It's like this.

#define max 27
typedef struct ctype 
{
    struct ctype (*letter)[max];
    int counter
}trie

void main()
{
    trie t;
    int ctr;

    for(ctr = 0; ctr < max; ctr++)
        t.(*letter)[ctr] = NULL;
}

I have a problem in both declaration and accessing. I've tried googling it but I can't understand the syntaxes. Please correct my code.

Recommended Answers

All 2 Replies

Um, there's more to a trie than that. Have you worked with binary search trees before? Tries are a more general tree structure where the number of nodes isn't restricted.

void main()
{
    trie t;
    int ctr;

    for(ctr = 0; ctr < max; ctr++)
        t.(*letter)[ctr] = NULL;
}

You have to write

for(ctr = 0; ctr < 10; ctr++)
                t.letter[ctr]=NULL;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.