Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting a trie to a file - C

I have a trie which I am using to do some string processing. I have a simple compiler which generates trie from some data. Once generated, my trie won't change at run time.

I am looking for an approach where I can persist the trie in a file and load it effectively. I have looked at sqllite to understand how they are persisting b-treebut their file format looks bit advanced and I may not need all of those.

It'd be helpful if someone can provide some ideas to persist and read the trie. I am programming using C.

like image 752
Navaneeth K N Avatar asked Apr 03 '10 17:04

Navaneeth K N


1 Answers

I did some research and found the following little gems online:

  1. trie.h
  2. trie.c

A working trie with serialization and deserialization. It was originally written for use in Python (there's a corresponding triemodule.c for tying it to Python), but it's pure C; you could mine it for ideas or use it as you wish.

Update:

It appears the links are no longer working. I'll keep the originals up, but here are the links in the wayback machine:

  1. trie.h
  2. trie.c
like image 157
Randolpho Avatar answered Oct 22 '22 10:10

Randolpho