bAh
Junior Member
Posts: 23
|
Post by bAh on Mar 11, 2002 0:24:47 GMT -5
woh..... it seems like 148's assignment's requirements are getting pickier everytime eh.... ok.... this assignment... we have to use recursion ONLY... and no loops.... so according to their handout... they wanted to have a root node with some vector/array/LL list type of stuff storing the references to children nodes rite? But then they wanted it to be sorted.. how am i supposed to do it? and.... considering that we cannot assume the tree to be binary, so it means we have to cycle through the list (vector/array/LL) containing the references..... i don't realy have a clear idea on how that can be worked out.... can somebody HELP PLZZZZZ p.s. i hope someone's gonna be happy about what i'm gonna put on the course-evaluation sheet sometime during april.... ;D p.p.s anyone done with the assignment?
|
|
|
Post by Evotamer on Mar 11, 2002 0:39:54 GMT -5
This should work... even without loops and using only recursion
If you insert something you can go look at the element at the head of the list and add it if it belongs at that spot. Insert it and link it accordingly. If it doesn't fit in at that spot, use recursion on the rest of the list(keep doing this till you really do insert where you want it to go).
I'd put up pesudocode to do this, but well, it's up to you to figure that out so you can learn the material well. But hopefully I gave you a hint or guideline you should follow (you need to figure out special cases).
|
|