[Tutor] A Faq can be a tree (long)

Remco Gerlich scarblac@pino.selwerd.nl
Mon, 14 May 2001 09:33:22 +0200


On  0, VanL <van@lindbergs.org> wrote:
> The data structure implementing this faq would be:
> 
> Root faqentry (members: title, head, children)
> The childrenlist would point to:
> 1. faqentry (members: tree question, answer children=None)
> 2. faqentry (members: FAQ question, answer, children=None)
> 3. faqentry (members: Question 6, answer, children=None)
> 
> Anyway, in this way, the faq could have an arbitrary number of subsections that would
> all "know" their relationship to the parent structure by their place in the tree.  The
> advantage of this over the dictionary implementation that you propose is:
>         1. No namespace collision for child entries (ok, you would need a really large
> faq to actually run into this problem)
>         2.  Inserting a new question/answer would automatically renumber anything
> necessary, which would be a big time win for large complicated faqs.

But when you renumber, would the hyperlinks still work? Oh right, you could
update all the contents of all the leaves.

But people refer to your FAQ from other places as well. Renumbering existing
items gives problems anyway.

I never meant a tree was a wrong way to go about it, just that your
reasoning "I want a FAQ - hey I could do this with a tree - let's make a
tree!" was a bit shallow :). You know have great detail on *how* you would
do it, but still not all that much reasoning *why*, and only about a single
data structure. Luckily, this is Python, so implementing it is pretty
trivial, and you can try two or three others afterwards to see if you like
them better :).

> If you still think I'm on drugs for thinking that I should implement a faq as a tree,
> tell me.  That was just my thinking.

Not at all. It's certainly possible. It just wasn't clear to me that it was
the best way.

-- 
Remco Gerlich