tree

How do you sort a tree stored using the nested set model?

When I refer to nested set model I mean what is described here. I need to build a new system for storing "categories" (I can't think of better word for it) in a user defined hierarchy. Since the nested set model is optimized for reads instead of writes, I decided to use that. Unfortunately during my research and testing of nested sets...

How to search a string based key/value collection fast

Hello fellow stackoverflowers! I have a word list of 200.000 string entries, average string length is around 30 characters. This list of words are the key and to each key i have a domain object. I would like to find the domain objects in this collection by only knowing a part of the key. I.E. the search string "kov" would for example ma...

Find leaf nodes in hierarchical tree

I have a table in my database which stores a tree structure. Here are the relevant fields: mytree (id, parentid, otherfields...) I want to find all the leaf nodes (that is, any record whose id is not another record's parentid) I've tried this: SELECT * FROM mytree WHERE `id` NOT IN (SELECT DISTINCT `parentid` FROM `mytree`) But th...

Why does the C++ STL not provide any "tree" containers?

Why does the C++ STL not provide any "tree" containers, and what's the best thing to use instead? I want to store a hierarchy of objects as a tree, rather than use a tree as a performance enhancement... ...

Summing up all nodes

This may be a simple fix - but I'm trying to sum together all the nodes (Size property from the Node class) on the binary search tree. Below in my BST class I have the following so far, but it returns 0: private long sum(Node<T> thisNode) { if (thisNode.Left == null && thisNode.Right == null) return 0; ...

How would you design a tree view that collapses around an arbitrary middle element?

I've got an project management web application where any Project can be the child of zero or one other Project. Our director uses this function to group projects into Service Offerings, and our project managers use this to break projects down into tasks... but from the database's point of view, they're all in the Projects table. So the...

C++ Binary Search Tree Recursive search function

template <class T> bool BST<T>::search(const T& x, int& len) const { return search(BT<T>::root, x); } template <class T> bool BST<T>::search(struct Node<T>*& root, const T& x) { if (root == NULL) return false; else { if (root->data == x) return true; else if(root->data < x) search(root->left, x); ...

Binary Search Tree Deletion (Inorder Pred method) C++

Ok so I thought it was fixed, but I'm getting totally inconsistent results. I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure where else to go template...

How can I preload records with parent-child self-references using Castle ActiveRecord?

My SQL table looks like this: CREATE TABLE Page ( Id int primary key, ParentId int, -- refers to Page.Id Title varchar(255), Content ntext ) and maps to the following class in my ActiveRecord model: [ActiveRecord] public class Page { [PrimaryKey] public int Id { get; set; } [BelongsTo("Parent")] publ...

The Big Tree: When to Release Data in an RIA

This question is about a Java JTree or a Window .Net Tree (Winforms) or an Adobe Flex Tree. In a client-server application (for Flex it's Web, really), I have a tree with hierarchical data (in a Windows Explorer type interface). Right now I lazily load up the tree as the user requests more data from the server. This is fine and will wor...

How do I limit tree nodes from being dragged from their current node in flex 3?

So I have a flex tree component with a xmllistcollection as it's data provider. I would like to be able to rearrange the leaves and branches in the tree by drag and drop. I want to limit the drop area to the current level of the item being dragged. Like branch branch 0 leaf 1 leaf 2 branch x ...

Using C# and gppg, how would I construct an abstract syntax tree?

Is there a way to do this almost out-of-the-box? I could go and write a big method that would use the collected tokens to figure out which leaves should be put in which branches and in the end populate a TreeNode object, but since gppg already handled everything by using supplied regular expressions, I was wondering if there's an easier...

Tree library for PHP using left & right ids

I'm looking for a library in PHP that can create a tree structure from a database (or array of values) with left and right ids. For the result when getting values I am only looking for an array so I can create any type of view. For adding and removing, it would be nice if the library did it all. Even if the library is within another libr...

How would I create a syntax tree using gppg?

What would be the easiest way of accomplishing this, assuming I'm already able to use gppg for syntax analysis? I don't know how to check which non-terminating symbols a parser had to go through in order to set the token in its rightful place (or, failing that, report an error). Any help would be greatly appreciated! ...

What's a good way to rewrite this non-tail-recursive function?

For some reason, I am having trouble thinking of a good way to rewrite this function so it uses constant stack space. Most online discussions of tree recursion cheat by using the Fibonacci function and exploiting the properties of that particular problem. Does anyone have any ideas for this "real-world" (well, more real-world than the Fi...

Does stl in c++ have tree data structure.If not any c++ implementation for tree structure?

Does stl in c++ have tree data structure.If not any c++ implementation for tree structure? http://stackoverflow.com/questions/205945 ...

Want to save binary tree to disk for "20 questions" game

In short, I'd like to learn/develop an elegant method to save a binary tree to disk (a general tree, not necessarily a BST). Here is the description of my problem: I'm implementing a game of "20-questions". I've written a binary tree whose internal nodes are questions and leaves are answers. The left child of a node is the path you'd...

Best way to represt n/ depth tree for use in PHP (MySQL / XML / ?)

I am currently in the process of rewriting an application whereby teachers can plan curriculum online. The application guides teachers through a process of creating a unit of work for their students. The tool is currently used in three states but we have plans to get much bigger than that. One of the major draw cards of the application...

Flex - databinding from a Tree to a Repeater

Hi, I'm trying to make an XML questions editor in flash. Basically I load in the XML into a Tree component - XML like so: <questions> <question id="1" type="radio" text="This is question 1" isBranch="true"> <option id="1.1" correct="false" text="This is option 1" /> <option id="1.2" correct="false" text="This is option 2" /> <opti...

Implementing a tree from scratch

Hello everyone, I'm trying to learn about trees by implementing one from scratch. In this case I'd like to do it in C# Java or C++. (without using built in methods) So each node will store a character and there will be a maximum of 26 nodes per node. What data structure would I use to contain the pointers to each of the nodes? Basica...