tree-traversal

Numbering Regex Submatches

Is there a canonical ordering of submatch expressions in a regular expression? For example: What is the order of the submatches in "(([0-9]{3}).([0-9]{3}).([0-9]{3}).([0-9]{3}))\s+([A-Z]+)" ? a. (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3}))\s+([A-Z]+) (([0-9]{3})\.([0-9]{3})\.([0-9]{3})\.([0-9]{3})) ([A-Z]+) ([0-9]{3...

In-order tree traversal

I have the following text from an academic course I took a while ago about in-order traversal (they also call it pancaking) of a binary tree (not BST): In-order tree traversal Draw a line around the outside of the tree. Start to the left of the root, and go around the outside of the tree, to end up to the right of the root. ...

C# Large Tree Iteration

I have a large result set assembled in a parent/child relationship. I need to walk the tree and display the results to the user. I've done this before using recursion, but because my result set may be large, I want to avoid the possibility of receiving a StackOverflowException. I found the following example on MSDN which uses a Stac...

"Repassing" function arguments

Hi all! I'm doing this class assignment, using classic C, and am stuck with this problem about callback functions that take variable arguments count and type. Basically, I'm working on a Hashed Tree (a tree where each of the nodes is a hash tree), and I have a certain traversal strategy that will be used multiple times for different pur...

Breadth First Vs Depth First

When Traversing a Tree/Graph what is the difference between Breadth First and Depth first? Any coding or pseudocode examples would be great. ...

Modified preorder traversal for comment system

Hi, I'm trying to make a comments system for a blog. I have the modified preorder traversal system working (used this guide: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html). I have a few issues though. I do not think that guide explains how to manage having different blog posts, and adding a comment that is not a re...

Tree traversal without recursive / stack usage (C#) ?

Hi folks. I'm working with WPF and I'm developing a complex usercontrol, which is composed of a tree with rich functionality etc. For this purpose I used a View-Model design pattern, because some operations couldn't be achieved directly in WPF. So I take the IHierarchyItem (which is a node and pass it to this constructor to create a tree...

constructing random "integer" tree - depth-first / breadth-first

Hi, This is my first ever attempt at writing a recursive function in c. The following-code works. I apologize for the long posting, but I am trying to be as clear as possible. I am trying to generate a tree where each node (inode) has an integer field "n". Correspondingly, each inode has an array of pointers to "n" other inodes. Func...

Binary Tree Nodes - Which Way?

For an assignment we were given in Data Structures, we had to create a test class to determine whether the code we were given correctly traversed the binary trees in our test class. These are the 3 constructors for BinaryTreeNode class that was given to us: public BinaryTreeNode(Object theElement, BinaryTreeNode theleftChild, BinaryTre...

Tree traversal algorithm for directory structures with a lot of files

When recursively traversing through a directory structure, what is the most efficient algorithm to use if you have more files than directories? I notice that when using depth-first traversal, it seems to take longer when there are a lot of files in a given directory. Does breadth-first traversal work more efficiently in this case? I have...

Visualisation of Tree Hierachy in HTML

I am looking of inspiration for doing interaction design on a hierachy/tree structure. (products with a number of subproducts, rules that apply for selecting subproducts). I want to have a tree where there is a visible connection between sub-nodes and their parent node. And i also want to visualize which rules that apply for selecting t...

PHP Traversing Function to turn single array into nested array with children - based on parent id

I have an array similar to this: Array ( Array ( [ID] => 1 [parentcat_ID] => 0 ), Array ( [ID] => 2 [parentcat_ID] => 0 ), Array ( [ID] => 6 [parentcat_ID] => 1 ), Array ( [ID] => 7 [parentcat_ID] => 1 ), Array ( ...

Help me understand Inorder Traversal without using recursion

I am able to understand preorder traversal without using recursion, but I'm having a hard time with inorder traversal. I just don't seem to get it, perhaps, because I haven't understood the inner working of recursion. This is what I've tried so far: def traverseInorder(node): lifo = Lifo() lifo.push(node) while True: ...

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...

C++ TCL (tree container library): How to traverse a tree from a node straight to root

I am using this library to hold information about tree structure: http://www.datasoftsolutions.net/tree_container_library/overview.php Here is simplified version of my C++ code: #include "tcl/sequential_tree.h" // Node has some data which is not important now typedef sequential_tree<Node> gametree_t; typedef sequential_tree<Node>::i...

Big O for this recursive algorithm

I did the following algorithm involving a Binary Heap structure: Algorithm: heapMinimum(node) Input : Position n Output : Sequence minList; containing the postions that hold the minimum value 1. minList <-- sequence 2. if parent(node) == NULL // current node is the root of the tree 3. minList.insertLast(node) 4. if (leftchild(no...

Php Post Traversal tree for game states.

I am making a decision tree in php and trying to get it to display right. It starts with a root node which is the initial gamestate. Then you are able to create more gamestates and connect the nodes together to design what will happen if the user makes a choice and what node it is supposed to go to. Right now the display is getting me...

How can i get selector from jQuery object

Hi! $("*").click(function(){ $(this); // how can i get selector from $(this) ? }); Is there easy way to get selector from $(this) or something like that? There is a way, how to select element by selector, but how about getting selector from element? Thanx for any help =) ...

lists searches in SYB or uniplate haskell

I have been using uniplate and SYB and I am trying to transform a list For instance type Tree = [DataA] data DataA = DataA1 [DataB] | DataA2 String | DataA3 String [DataA] deriving Show data DataB = DataB1 [DataA] | DataB2 String | DataB3 String [DataB] ...

jquery Tree Traversal prev() problem.

Hello, I like to click a label and check the previous checkbox. I've tried the next code, but this is not working. I have tried for 2 hours, but what am i missing? JQUERY jQuery(document).ready(function() { $('.namelabel').live('click', function() { if ($(this).prev("input:checked").val() != null) { $(this).pr...