Questions tagged [modified-preorder-tree-t]
22 questions
8
votes
2 answers
Storing Composite Patterns (Hierarchical Data) in Database
What are 'best-practices' for saving Composite patterns in a Relational Database?
We have been using Modified Preorder Tree Traversal. This is very quick to build the whole tree, but very slow to insert or delete new nodes (all left and right values…

Lieven Cardoen
- 25,140
- 52
- 153
- 244
8
votes
3 answers
data structure for traversal tree in PHP?
I don't have a background in CS or data structures. I want to make a PHP class that stores a modified preorder transversal tree, for manipulation and syncing with a database.
Basically I need to store data…

user151841
- 17,377
- 29
- 109
- 171
7
votes
2 answers
How to generate a tree view from this result set based on Tree Traversal Algorithm?
I have this table:
CREATE TABLE `categories` (
`id` int(11) NOT NULL auto_increment,
`category_id` int(11) default NULL,
`root_id` int(11) default NULL,
`name` varchar(100) collate utf8_unicode_ci NOT NULL,
`lft` int(11) NOT NULL,
`rht`…

Keyne Viana
- 6,194
- 2
- 24
- 55
3
votes
1 answer
Modified preorder tree traversal: Selecting nodes 1 level deep
I have hierarchical ordered data saved using the modified preorder tree traversal algorithm.
Here's tables content:
id lft rgt name
1 1 10 topnode
2 2 3 level1
3 4 7 level1
4 5 6 level2
5 8 9 …

netiul
- 2,737
- 2
- 24
- 29
3
votes
4 answers
Numeric Range Optimization
I have an set numeric ranges that I would like to optimize.
Here's a simple example of initial values:
Start End
9 12
1 2
60 88
10 11
79 80
What I'd expect as output after optimization:
Start End
1 2
9 …

Sonny
- 8,204
- 7
- 63
- 134
1
vote
0 answers
Modified pre-order tree traversal - order children by score
So I have been able to output the data how I want except now I want to be able to rearrange it depending on the score of individual items. So right now I output something like this:
-
Item1
-
subitem1A
-
…

qitch
- 829
- 3
- 12
- 21
1
vote
0 answers
Updating comments in a modified preorder tree traversal. Do I need to lock the rows?
Your basic comment/reply system sorted with the premodified tree traversal. Sample output could look like this:
CommentA
SubcommentA-1
SubcommentA1-1
SubcommentA-2
CommentB
And so forth. When a user makes a comment then all the…

qitch
- 829
- 3
- 12
- 21
1
vote
3 answers
Modified preorder tree traversal - determining the "top" when no parent is specified
I'm implementing a Modified preorder tree traversal class for a category tree on a Web site, but I'm having trouble with one scenario. Typically when inserting a new category a top-level parent is specified, whose left value in the tree is used in…
user4903
1
vote
2 answers
How to balance binary tree in PHP without rotating parent?
I will try to make myself as clear as possible. Based from Adjacency List Model: http://articles.sitepoint.com/article/hierarchical-data-database
I need a way to balance this tree
0
/ \
1 2
/ / \
3 4 5
\ \
…

OBL
- 367
- 1
- 4
- 13
1
vote
0 answers
Partial replace on a modified preorder tree traversal from script
I have a MPTT (modified preorder tree traversal) like this:
(taken from SitePoint)
My real tree has thousands of nodes and a more complex structure, but this is a simplification that shows the problem.
Until this moment, every time I need to…

Ivan
- 14,692
- 17
- 59
- 96
0
votes
1 answer
Modified Preorder Tree Traveral - Enclosing in divs
-EDIT- would probably be better but the same question still applies.
So I have everything working as far as I can display the data and get the expected results. The display portion I have is coming from the article at…

qitch
- 829
- 3
- 12
- 21
0
votes
1 answer
How to make the result of a BFS spanning tree is shown in preorder
I'm trying to implement a BFS algorithm for homework, I find the spanning tree algorithm with BFS, the problem is that I require that the resulting spanning tree is shown in preorder. Here's my solution code:
#include…

AndrewRelex
- 1
- 1
0
votes
1 answer
Why when printing the preorder traversal of a BST my program does nothing
I'm trying to make a code that allows me to enter a tree node and then indicate its preorder traversal, but do not understand what happens. What am I doing wrong?
This is my code:
#include
#include
#include
#define MAX…

novaKid
- 233
- 2
- 4
- 11
0
votes
1 answer
How to indicate preorder of a spanning tree using the algorithm BFS
I'm doing an implementation of the BFS algorithm in c++ to find a spanning tree, the output for a spanning tree should be shown in preorder, but I have a doubt in the implementation, how I can build a tree if not exactly know how many children have…

franvergara66
- 10,524
- 20
- 59
- 101
0
votes
1 answer
Is the spanning tree found by the algorithm DFS always show in preorder?
I'm doing an implementation of the DFS algorithm in c + + to find a spanning tree, the output for a spanning tree using the algorithm DFS is always preorder or is it pure coincidence?.

franvergara66
- 10,524
- 20
- 59
- 101