Darren New <dne### [at] san rr com> wrote:
> I think that would work with the caveat that you have to distinguish between
> nodes without a child and nodes whose only child is '\0'. That is, not all
> your branches will end in a '\0' as shown in the picture.
Each node needs a bit of information denoting whether it's an end node
or not (ie. whether that node is the last character of a string stored in
the data structure or not) regardless. For example, if you store "CAT" and
"CATS" as two separate strings, you'll need a bit in the 'T' node to
indicate that there exists a string which end there.
Doing it like I suggested doesn't change anything. For the extraneous
nodes you simply set the bit to "no string ends here".
--
- Warp
Post a reply to this message
|