tree

Looking for a word for "flattening a tree"

I'm wondering if there's an existing word to describe a process that I'm currently using. I want to call it "flattening a tree" but I feel like there must be a better word or phrase. input: |--D --B | |--C | A-E | | |--G --F |--H output: [ [A, B, D] [A, B, C] [A, E] [A, F, G] [A, F, H] ] Is there an established name f...

Computing number of arrays containing an element in perl

I think I've just been looking at this too long. I have some data that looks like this: @a = ( { name => 'ethan', depth => 0 }, { name => 'victoria', depth => 1 }, { name => 'stephen', depth => 2 }, { name => 'christopher', depth => 3 }, { name => 'isabella', depth => 2 }, { name => 'ethan', depth => 3 }, { ...

How to convert a tree recursive function ( or algorithm ) to a loop one?

I have written a recursive Tree Function in pascal ( or delphi ) but i had an 'Out of Memory' message when I ran it. I need to turn the Calculate recursive function in this code to non-recursive function, can you tell me how please : program testing(input,output); type ptr = ^tr; tr = record age:byte; left,right:ptr; end...

Is there a faster way to get subtrees from tree like structures in python than the standard "recursive"?

Let's assume the following data structur with three numpy arrays (id, parent_id) (parent_id of the root element is -1): import numpy as np class MyStructure(object): def __init__(self): """ Default structure for now: 1 / \ 2 3 / \ 4 5 """ self.ids = np.array([1,2,3,4...

How is it possible for Boruvka's algorithm's complexity to be O(E*logV)?

1 Begin with a connected graph G containing edges of distinct weights, and an empty set of edges T 2 While the vertices of G connected by T are disjoint: 3 Begin with an empty set of edges E 4 For each component: 5 Begin with an empty set of edges S 6 For each vertex in the component: 7 Add the cheapest edge from...

General Purpose Decision Tree Algorithm Code Implementations

Are there any well-designed, general purpose decision tree implementations for iPhone or Java? I know with LINQ it would be quite trivial, but with Objective C and Java, it would be much more complex. Basically, I want to drill down a set of objects based off any number of qualifications or attributes in my apps. ...

Django: Store Hierarchical Data

Hi, I'm trying to store sections of a document in a Django app. The model looks like: class Section(models.Model): project = models.ForeignKey(Project) parent_section = models.ForeignKey('Section', blank=True, null=True, related_name='child_set') predecessor_section = models.ForeignKey('Section', blank=True, null=True, related_na...

what is the best way to store a tree structure in a relational DB?

There is the: put a FK to your parent method , i.e. each records points to it's parent Which is a hard for read actions but very easy to maintain And then there is a directory structure key 0001.0000.0000.0000 main branch 1 0001.0001.0000.0000 child of main branch one etc Which is super easy to read, but hard to maintain. Wha...

Seg Fault in Knowledge Tree

I am implementing a knowledge tree in c that can read from a file. I am getting a seg fault in my newStr function. I'm not able to test the rest of my code with this problem. I don't have much experience with c. Any help would be greatly appreciated. my .c file #include #include #include"animal.h" #inclu...

What is the order in this Union by Rank diagram?

Hi, I'm having trouble understanding the following diagram: Why is A linked to D instead of B? Why is C linked to F instead of D? ...

Can't pinpoint Segmentation fault

Possible Duplicate: Seg Fault in Knowledge Tree I can't pinpoint my seg fault in my information tree. It is supposed to read from file or get user input if the file does not exist. It's supposed to guess the animal based on yes or no questions. I have limited experience with c so any help would be greatly appreciated. .c fil...

Postorder tree traversal with clojure.zip to edit nodes

I have a tree represented as a nested vector. I want to have a generalization of indexed for trees, showing the index of each node like this, (visit 42); => [0 42] (visit [6 7]); => [0 ; [[0 6] ; [1 7]]] The naive implementation would use clojure.zip directly (as already asked here) (defn visit [...

Hibernate Parent/Child SELECT N+1 issue

Hi Folks (and Pascal), I jave the following mapped superclass that provides a basic implementation for a parent/child self relationship to create a parent/child list for unlimited nesting of items (i.e. Categories) @MappedSuperclass public abstract class ParentChildPathEntity<N extends ParentChild> implements MaterializedPath<N> { ...

how to avoid parameter type warning for self referencing typesafe interface in java?

I am working with tree's in java and I have the following interface for a simple unordered tree with a self reference: public interface Node<N extends Node> { public N getParent(); public void setParent(N parent); public Collection<N> getChildren(); public void addChild(N node); public void removeChild(N node); public N ...

Recursive (pedigree) tree building from (child, parent) list in Python

Hi All, I have as input a list of tuples (child, parent). Given that a child only have one parent. I would like for every child to build an ordered ancestors list. Any tip ? input would be like : [('3', '4'), ('1', '2'), ('2', '3')] output would be like: 1, [2, 3, 4] 2, [3, 4] 3, [4] 4, [None] ...

How do I put color on a virtual string tree node?

Is it possible for a virtual string tree to look like this? i really need help on this since i'm new in delphi.. ...

which is the best Jquery Tree plugin , easy to Customize.

i find two : 1.jstree 2.TreeView whicih is better ? and has any other better choices? thanks ...

Convert a binary tree to linked list, breadth first, constant storage/destructive

This is not homework, and I don't need to answer it, but now I have become obsessed :) The problem is: Design an algorithm to destructively flatten a binary tree to a linked list, breadth-first. Okay, easy enough. Just build a queue, and do what you have to. That was the warm-up. Now, implement it with constant storage (recursion, ...

how to form a tree structure from DB2 Table(s)?

Please refer to this question database-structure-for-tree-data-structure Is this possible in DB2 Database? I know it is possible in Oracle using START WITH and CONNECT BY, i don't have any idea in DB2, Is it possible to achieve this in DB2? Thanks! ...

What's wrong with this copy constructor?

I've been trying to come up with a copy constructor for a tree. I've found quite a few suggestions. This one interested me. class TreeNode { int ascii; TreeNode* left; TreeNode* right; public: TreeNode() { ascii = 0; left = right = 0; } TreeNode* clone(); // ... }; TreeNode* TreeNode::clone() { ...