A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
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.
anonymous
 5 years ago
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.

This Question is Closed

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0I'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.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Hey thanks for the reply. I have to do mine with OOP though like: class Node class Family etc.

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0have you worked with linked lists at all? I should be similar? except that it points too 2 places instead of 1

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0My current implementation for the Node is: class Node(object): 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.

mattc
 5 years ago
Best ResponseYou've already chosen the best response.0I found an implementation of a binary tree, might help, http://code.activestate.com/recipes/286239binaryorderedtree/ unfortunately i do not know much about implementing a tree data structure or what you mean by a family.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Sorry I meant Tree, the Tree is to represent a Family
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.