tree

Sorting modified preorder traversal mysql tree

Hey, I've implemented a tree in a mysql table using: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html This is the method where you have a table like: +-------------+----------------------+-----+-----+ | category_id | name | lft | rgt | +-------------+----------------------+-----+-----+ | 1 ...

Tree Structures

What are the benefits or advantages to using a tree structure in a managed language or framework over flat structures provided by said language or framework, aka .NET, and are there any libraries for such a structure? ...

how can i list every path in a directed graph? (C#)

please just point me in the right direction or tell me what to look up to solve this: I have a "tree" object that holds "node" objects. (actually it's called a directed graph). Each node holds the fields string "name" and "list" that contains the next nodes. How can I create lists of all possible node names from the head node to the fo...

Construct a tree structure from list of string paths

I have a collection of string paths like ["x1/x2/x3","x1/x2/x4","x1/x5"] in a list. I need to construct a tree-like structure from this list which can be iterated to get a pretty printed tree. like this x1 | |-x2 | | | |-x3 | | | |-x4 | |-x5 Any ideas/suggestions? I believe that the problem can be attacked first by processing the ...

Accessible navigation of large information trees

I am developing a public website which is the front end to information about medical conditions. After the user does a search (questionnaire based) they are presented with the results which are categorised in to sections and sub-sections. Information items can be assigned to both sections and sub-sections. At the moment sections are...

How should I structure my ViewModel for this hierarchical data I need to display in ASP.NET MVC?

I have a view that will look like this: I'm trying to figure out how I should represent my ViewModel for this view. Each "Agency" can have multiple "Business Units" and each "Business Unit" can have several "Clients". In the database I easily represent this with a mapping table and foreign keys for the Agency, BusinessUnit and Clien...

OO Design Question -- Parent/Child(ren) -- Circular?

I'm fairly new to the OO design process, so please bear with me.... I have two entities that I need to model as classes, call them Parent and Child (it's close enough to the actual problem domain). One Parent will have one or more Children -- I have not interest, in this application, in childless Parents. Where my brain is going out to...

What algorithm can I apply to this DAG?

I have a DAG representing a list of properties. These properties are such that if a>b, then a has a directed edge to b. It is transitive as well, so that if a>b and b>c, then a has a directed edge to c. However, the directed edge from a to c is superfluous because a has a directed edge to b and b has a directed edge to c. How can I prun...

Representing a tree structure out of a db

Hi to all, I've read about various ways of representing hierarchical structure within a relational database like Adjacency List. I have decided to try a straight forward way like a table (oversimplified) done like this: id | name | parent where parent is a inner reference to id. This should be enough to represent a simple tree of undef...

ASP.NET Editable Tree View

Hi, I am trying to build an editable tree hierarchy similar to treeview control only with the ability to add, remove and rename documents aswell as the ability to view them. Anybody recommend a good way of doing this? I am a PHP person, fairly new to .NET so any help would be greatly appreciated. Thanks, Sean ...

Problem with dojo tree

Hello, I'm trying to get the dojo tree widget working. It works with a small json object, but when i try it with a large json object it goes wrong. There is no error, just the root node. Is this a normal behavior? Is there a maximum of objects you can load? My json object contains around 800 entries. Thanks, Ewout ...

Multi-way tree

How do you find the height of a multi-way tree? A binary tree looks something like this... int height(node *root) { if (root == NULL) return 0; else return max(height(root->left), height(root->right)) + 1; } I cant figure it for multi-way. ...

Find first null in binary tree with limited memory

I have a binary tree where each node can have a value. I want to find the node in the tree that has value null and is closest to the root. If there are two nodes with the same distance from the root, either will do. I need to minimize the number of read accesses to the binary tree. Assume that working memory is limited to just k node...

Reasonable size of a Tree and Dictionary

I'm currently implementing a very complex tree structure to allow for near-instant data access, instead of re-processing on each request. I'm just wondering if there is a theoretical, or practical, limit at which the size of a tree becomes too big, or a point at which a dictionary becomes too collision-filled to function correctly/quick...

Big O help

If i had a function like this... void myfunction(node* root) { for(int i = 0; i<root->children.size();i++) { myfunction(root->children[i]); } } granted thats just the part of the function I have a question on, but would that be n^2 or just n, for big O? I guess the question is if you have a for loop and inside that for...

Easiest way to build a tree from a list of Ancestors

In my heart, I feel that there must be a super simple recursive solution to this, but I cannot immediately grok it. I have a tree stored in SQL as a closure table. The tree looks like: (1 (2 (3), 4)), and the languages are MySQL's SQL and PHP 5.3. The closure table is thus: +----------+------------+ | ancestor | descendant | +-------...

Percentages and trees

Hi, I have an unordered tree. Each node represents a task that can be done (1), not done (0) or have children tasks. For example: 1 -1.1 -1.2 --1.2.1 --1.2.2 -1.3 2 3 -3.1 4 -4.1 --4.1.1 5 Suppose that the leaves 1.2.1, 3.1 and 5 are done 1 -1.1 -1.2 --1.2.1* --1.2.2 -1.3 2 3 -3.1* 4 -4.1 --4.1.1 5* I want to calculate the percen...

Unable to show a Git tree in terminal

The article has the following inputs and outputs git co master git merge [your_branch] git push upstream A-B-C-D-E A-B-C-D-E-F-G \ ----> \ your branch C-D-E G I am interested how you get the tree like-view of commits in your terminal without using Gitk o...

How do I calculate tree edit distance?

I need to calculate the edit distance between trees for a personal project of mine. This paper describes an algorithm, but I can't make heads or tails out of it. Are you aware of any resources that describe an applicable algorithm in a more approachable way? Pseudocode or code would be helpful, too. ...

Java Crit-bit Trees

Is there a built-in data structure in Java to represent a Crit-bit tree? Or any libraries available that might provide this functionality? I would also accept brief code as an answer, if one can be implemented in a simplistic brief way. ...