It doesn't come up much in the class but does anyone know much about implementing a Tree Data Structure in python. I'd like to find a tutorial about how to do one to represent a family. Thanks.
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
I'm currently working on problem set 8, and in this problem set you have to use a binary tree. It uses recursion to transverse the tree and uses it to solve a Knapsack Problem. Might be helpful. Although I am having trouble with this problem set at the moment.
Hey thanks for the reply. I have to do mine with OOP though like:
class Family etc.
have you worked with linked lists at all? I should be similar? except that it points too 2 places instead of 1
Not the answer you are looking for? Search for more explanations.
My current implementation for the Node is:
def __init__(self, name):
self.name = name
self.children = 
self.parent = None
for item in relationdict:
if relationdict[item] == self.name:
self.children.append(item) relationdict is just a dictionary mapping sons to fathers
This is working fine but when I try to extend it to make a family I keep failing.
I found an implementation of a binary tree, might help, http://code.activestate.com/recipes/286239-binary-ordered-tree/
unfortunately i do not know much about implementing a tree data structure or what you mean by a family.
Sorry I meant Tree, the Tree is to represent a Family