tree

how to get the maximum depth of an html tree ?

say i have an html page parsed via Nokogiri. how can i find the maximum depth of the tree ? do i iterate through each element and count how many ancestors it has ? is there a more efficient approach ? ...

How to represent a data tree in SQL?

I'm writing a data tree structure that is combined from a Tree and a TreeNode. Tree will contain the root and the top level actions on the data. I'm using a UI library to present the tree in a windows form where I can bind the tree to the TreeView. I will need to save this tree and nodes in the DB. What will be the best way to save the ...

database tree to multidimensional array

Hi, i have a simple database tree with parentid and i want to read the db and get an array like above Array ( Title: Category 1 Children => Array ( => Title: Category 1.1 => Title: Category 1.2 Children => Array ( ...

Entity framework: Access / modify the Command Tree or otherwise provide custom mapping C# functions

Hello, I'm investigating a method of providing transparent bi-temporal versioning of entities with Entity framework 3.5 or 4.0. What I want to do: When an entity is saved, the former entity has to be copied into a separate table, for example, if the entity is Customer, it will be saved in Customer_AUD. Upon retrieval, based on date/ver...

Construct a Tree

How can I construct a tree given its inorder and preorder traversal? I am just looking for an efficient algorithm. ...

Recursive N-way merge/diff algorithm for directory trees?

What algorithms or Java libraries are available to do N-way, recursive diff/merge of directories? I need to be able to generate a list of folder trees that have many identical files, and have subdirectories with many similar files. I want to be able to use 2-way merge operations to quickly remove as much redundancy as possible. Goals...

Unable to refresh tree control with new branches from successful RemoteObject call

I'm trying to populate a mx:tree component with values that I'm getting from BlazeDS. The returned data from BlazeDS is fine - it's an ArrayCollection of Folder value objects. I've been instructed to use Cairngorm for this project. I'm pretty new to Flex and Cairngorm. According to the limited documentation that I've read online I shoul...

What is the definition for the height of a tree?

I can't seem to find a definitive answer for this, I'm trying to do some elementary proofs on heaps but here's what's throwing me off a little bit: Is an empty tree valid? If so, what is its height? I would think this would be 0. What is the height of a tree with a single node? I would think this would be 1 but I have seen definitions...

Flex Tree leaf-element highlighting while drag&drop

Hi, i have TileList from which i'm dragging some stuff(image) to Tree (something like dragging sounds into playlist in iTunes), but when i can drop this stuff, i see only underline, this mean i can drop it only under or above some leaf-element in that Tree. How can i force it to hide this black underline and highlight leaf-element to whi...

How do you compare the "similarity" between two dendrograms (in R) ?

I have two dendrograms which I wish to compare to each other in order to find out how "similar" they are. But I don't know of any method to do so (let alone a code to implement it, say, in R). Any leads ? Thanks, Tal ...

How are B Tree nodes typically represented?

I've been doing some brushing up on my B-Tree and 2-3-4 tree (B tree with order 4), and I'm attempting to implement this in C#. My question to you is, given that a B-Tree node can contains N-1 number of items and N subtrees, what is the typical representation for one of these nodes? Is it an array, series of linked-lists, or something I...

Pattern to map Generic Data Structure to a Specific Data Structure

I have a hierarchical generic data structure. There is a root node and under that there can be many tree nodes, or just a single data node, and tree nodes can have more tree nodes. A basic tree structure. All data in my system is persisted in this format. I do however want to have a strongly typed interface to some of the different type...

Trees: Linked Lists vs Arrays (Efficiency)

This is an assignment question that I am having trouble wording an answer to. "Suppose a tree may have up to k children per node. Let v be the average number of children per node. For what value(s) of v is it more efficient (in terms of space used) to store the child nodes in a linked list versus storage in an array? Why?" I believe I ...

Inserting a value into an ordered tree in Haskell

Hi Basically I have defined a Tree data type which is defined as follows: data Tree a = Empty | Leaf a | Node (Tree a) a (Tree a) deriving (Eq, Ord, Show) Now I have to create a function to insert a value into an ordered tree (it doesn't have to sort the tree, just add the value). This is what I've come up with so far: insert :: a -...

Query to search tree in database

I have a table in my database representing a tree. The data is stored using nested sets. I want to write a query to search the tree and return just the nodes that match a pattern, along with their ancestors and descendants. This is what I have come up with so far. SELECT DISTINCT Node, Parent, Description FROM Hierarchy INNER JOIN ...

Trie implementation

I am attempting to implement a very simple Trie in Java that supports 3 operations. I'd like it to have an insert method, a has method (ie is a certain word in the trie), and a toString method to return the trie in string form. I believe I have insertion working properly, but has and toString are proving to be difficult. Here's what I...

Strategy to implement tree traversing algorithm in parallel?

I have implemented an iterative algorithm, where each iteration involves a pre-order tree traversal (sometimes called downwards accumulation) followed by a post-order tree traversal (upwards accumulation). Each visit to each node involves calculating and storing information to be used for the next visit (either in the subsequent post-or...

Copy-Paste Data with tree structure

Hello, I have a treeList, loaded with data from SQL DB. The logigs in sql for tree is standart: ID, ParentID and other fields. Now i want to implement Copy-Paste in this tree. When I click on tree, and select "Copy" button on some node with some tree structure, i select to DataTable all information about that object and all his children,...

RDMBS: Approach for efficiently accessing tree structure data held in a database

Some details about the scenario: 1. We have a MS SQL Server 2008 database which stores 'Resource' records in a table. 2. Resources can have multiple child resources. 3. A child resource can belong to multiple parent resources. 4. Resources are linked to each other via an intermediary table, i.e. Resource -> Link -> Resource. 5. Th...

Algorithm for sorting a nested/adjecency model in Ruby

I've been trying to find a good way of doing this, either on the client side in Javascript or at the last minute within the server. This is a Rails application but it is a pretty generic question. I have a model that is hierarchical, and is currently stored in a nested set model. The model then has: parent_id, lft, and rgt I would lik...