tree

Efficiently selecting a tree in Linq-To-Sql

Hello! I have a linq-to-sql data layer, with 2 tables in it. "Parent" and "Child". There's a relationship between Child and Parent (so parent has many children, etc etc), a parent can also have many parents (when children grow up and themselves become parents). I want to display this hierarchy out to the user, but I'm not sure how to...

Tree Transformations Using Visitor Pattern

(Disclaimer: these examples are given in the context of building a compiler, but this question is all about the Visitor pattern and does not require any knowledge of compiler theory.) I'm going through Andrew Appel's Modern Compiler Implementation in Java to try to teach myself compiler theory (so no, this isn't homework) and I'm havin...

Accessibility of the YUI Tree control: how to tab to the tree on Firefox?

Consider this example showing the YUI tree in action: http://developer.yahoo.com/yui/examples/treeview/tv%5Fedit.html Select the title in orange ("TreeView Control: Inline Editing of TreeView Node Labels"). Hit tab a first time: the link "View example in new window" is selected. Hit tab a second time: this selects an anchor inside the...

Why is pointer-to-pointer being used in this prog ?

The following program shows how to build a binary tree in a C program. It uses dynamic memory allocation, pointers and recursion. A binary tree is a very useful data-structure, since it allows efficient insertion, searching and deletion in a sorted list. As such a tree is essentially a recursively defined structure, recursive programming...

What's the fastest way to deserialize a tree in C++

I'm working with a not so small tree structure (it's a Burkhard-Keller-Tree, > 100 MB in memory) implemented in C++. The pointers to the children of each node are stored in a QHash. Each node x has n children y[1] ... y[n], the edges to the children are labeled with the edit distance d(x, y[i]), so using a hash to store the nodes is an...

A recursive method to find depth of a any(not necessarily complete) Binary tree

I am trying to compute the depth of any(not necessarily complete) BST in O(log n) time recursively. This is the algorithm I came up with: //max() - returns the max of two numbers int depth(root) { if(root->left==NULL && root->right==NULL) //leaf return 0; else if(root->left!=NULL && root->right==NULL) //with right leaf ...

Delete multiple nodes from a binary search tree

Hello, I have a binary search tree created in c. The problem is I can't find a efficient way to delete all the nodes with e.g. id>5. When I traverse the tree, if I delete a node, the recursion is getting error, because the structure is not the same. Is there any way, instead of using a helping stack to keep the data before delete them...

Implementing IEnumerable on a tree structure

Based on the work of these guys: dvanderboom.wordpress.com/2008/03/15/treet-implementing-a-non-binary-tree-in-c/ www.matthidinger.com/archive/2009/02/08/asp.net-mvc-recursive-treeview-helper.aspx I am trying to implement a TreeView helper that would be used as such: <%= Html.TreeView("records", Library.Instance.Reco...

Is this valid XML?

I know that syntax is valid, but my question is whether it is logically valid: <parent> <name>John</name> <child>Mary</child> <child>Lucy</child> <child>Hannah</child> </parent> or a proper way to do this is: <parent> <name>John</name> <child> <name>Mary</name> </child> <child> <name>Lu...

Django - Using trees to build a comment system.

A few days back I was messing around with Django, trying to get a feel for how stuff works, when I decided to try and build a simple forum, one that resembled a forum that I frequented (but is now closed down). The idea was that each of the comments would be parent to any number of comments, like so: comment <--top comment <-- comme...

Multi-Root Tree Structure

I have a data such that there are many parents each with 0-n children where each child can have 0-n nodes. Each node has a unique identifier (key) Ultimately, the parents are not connected to each other. It seems like this would be a list of trees, however that seems imprecise. I was thinking of joining them with a dummy root. I need...

...

    returning and using multiple tree structures in a recursive function

    I have a function get_trees() that operates on a complex tree structure T and returns two component tree structures A and B. The only way I have been able tot get this to work is to create a new structure C with pointers to A and B, which is then passed as a parameter to the function and is also a return value: typedef struct Composite ...

    Populate a TTreeView With Directory Tree And Filtering

    On a Lazarus 0.9.28.2 project I have a TTreeView, with the name DirTree on my Form(frmConvert), but I want to populate it with all the directory tree, since C:\. Like this: And when the user select the directory, in the second TTreeView, with the name FileTree, appear all the files in that directory, but filtered to show only PDFs. A...

    Rich tree structures with PHP

    I'm finding it very difficult to find anything about creating maintanable, navigatable and verbose tree structures in PHP. I wanted to open it up to the SO community and see who's done what. The way I can see creating this sort of structure is to have an object for every node, with a reference to the parent or child nodes. I've yet to p...

    Data structure for handling intervals

    I have got a series of time intervals (t_start,t_end), that cannot overlap, i.e.: t_end(i) > t_start(i+1). I want to do the following operations: 1) Add new (Union of) intervals [ {(1,4),(8,10)} U (3,7) = {(1,7),(8,10)} ] 2) Take intervals out [ (1,7) - (3,5) = {(1,3),(5,7)} 3) Checking whether a point or a interval overlaps with an int...

    pointer to pointer problem

    Hi, I was studying trees and everything seem fine until i started a avl tree, which requires rotation. I built a rotation algorithm that works fine until the 2 or 3 rotation, the algorithm it's the following: static void _nodeRotateRight(avl_tree* t, avl_tree_node** n) { avl_tree_node* node = (*n)->left; // refresh parents before rota...

    Adjacency List Model with two tables

    So I think my issue boils down to two questions: How do I build a traversable tree structure in PHP when the tree is stored in MySQL (between two tables) using the Adjacency List Model approach while keeping performance in mind? What's a maintainable approach to displaying the tree in the needed formats without duplicating traversal co...

    Hashing a Tree Structure

    I've just come across a scenario in my project where it I need to compare different tree objects for equality with already known instances, and have considered that some sort of hashing algorithm that operates on an arbitrary tree would be very useful. Take for example the following tree: O / \ / \ O O ...

    Have multiple trees in one table using CakePHP Tree Behavior

    I'm converting a flat list into a tree in my CakePHP app and found that there is an existing behavior that has this functionality. My table is not one giant tree, but consists of many user-generated trees: basically, each user can create their own folder structure. However it seems that the Tree Behavior would only keep track of lft/rght...