Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C - Possible to create a tree level by level?

Name: Anonymous 2010-05-25 12:39

I'm studying trees right now, and I'd like to find some examples of how to create a binary(or k-ary) tree one level at a time, since I can't find it anywhere and my brain isn't working.

Anyone have any input on this? C's lack of functions doesn't help either. Thanks ahead, /prog/

Name: Anonymous 2010-05-25 14:12

>>2
That's assuming my tree is going to be complete which it isn't, and that I know its length from start, which I don't. I guess I should have mentioned that, sorry.
>>4
Could you elaborate? I think I kind of understand the concept but it's still not very clear to me. Code or pseudo-code example?


Thing is I'm facing an np-complete problem, and I want to build this tree one level at a time, checking if I reach the solution at each pass. I'm doing this because in my case the first solution I find will be the best(looking for the shortest path).

I already determined that a recursive function is probably not what I want for this purpose(could be wrong), but I've never seen an iterative tree creation function(haven't been programming for long), so that's why I'm a little lost.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List