Questions tagged [tree-structure]

110 questions
3
votes
2 answers

I need to show data in a drop down like a tree structure, I tried but could not get it right in ASP.Net

I am working on a CMS which supports multiple Language and i want drop-down to show "pageNames" created similar to example below Home Page Second Page -Child Page1 -Child Page2 Third Page -Child Page1 -Child Page2 -Child Page3 --Sub Child…
Learning
  • 19,469
  • 39
  • 180
  • 373
3
votes
4 answers

Best practice for storing tree data in a database

I think the classic form of the problem is you have employees and employees have managers so the manager has a manager unless he's the CEO. So how do you store the data? Solution 1: It would seem that the employee table can have manager_id or you…
Joe
  • 7,922
  • 18
  • 54
  • 83
3
votes
0 answers

Dynamic question answer tree structure in mongodb

I'm looking to build a question answer survey system where some questions will be based on the answer of the parent question. The hierarchy level of the questions can go any number of depth based on the questions. The questions and answers will be…
User 99x
  • 1,011
  • 1
  • 13
  • 39
3
votes
1 answer

MongoDB recusrive lookup query

I have a list of documents in a MongoDB with the following structure: { 'name': 'A', 'friends': ['B', 'C'] }, { 'name': 'B', 'friends': ['A'] }, { 'name': 'C', 'friends': ['A'] }, { 'name': 'D', 'friends': [] }, { 'name': 'E', …
Joba
  • 777
  • 7
  • 24
3
votes
2 answers

Duplicate / multiplicate tree efficiently

I need (for g++) a (computation time) optimized algorithm tree structure to duplicate/multiplicate a tree. My tree will be a k-ary tree, but not necessarily filled. The main operation is to multiplicate (up to k times) the existing tree and add the…
hardmooth
  • 1,202
  • 2
  • 19
  • 36
3
votes
2 answers

Dynamic Javascript Tree Structure

I would like to build the hierarchy dynamically with each node created as a layer/level in the hierarchy having its own array of nodes. THIS SHOULD FORM A TREE STRUCTURE.There should be a root node, and an undefined number of nodes and levels to…
2
votes
1 answer

How to obtain the interval limits from a decision tree with scikit-learn?

Say I am using the titanic dataset, with the variable age only: import pandas as pd data = pd.read_csv('https://www.openml.org/data/get_csv/16826755/phpMYEkMl')[["age", "survived"]] data = data.replace('?', np.nan) data =…
Sole Galli
  • 827
  • 6
  • 21
2
votes
4 answers

Creating an efficient friendlist using PHP

I would like to build a website that has some elements of a social network. So I have been trying to think of an efficient way to store a friend list (somewhat like Facebook). And after searching a bit the only suggestion I have come across is…
GolD
  • 23
  • 5
2
votes
2 answers

Python recursion to sort list of tuples into tree structure

I'm new to coding and got myself stuck trying to recursively sort a list of tuples. Here is my code: # table consists on [(code, parent), (code, parent), ...] table = [('1', ''), ('1.1', '1'), ('2', ''), ('2.1','2'), …
2
votes
3 answers

javascript tree structure - traverse tree structure and show the sum the count attribute inside children

So i have a tree stucture like below where i have a count attribute in the leaf nodes. i want to sum up the count and put the sum of counts against its parent. than so parent1 and parent2 have sum of their children. and than continue on from there,…
josh_boaz
  • 1,963
  • 7
  • 32
  • 69
2
votes
3 answers

Tree structure with parents and children

I'm trying to make a tree structure of parents and children. The problem is that I only want to be able to assign the parent of a child in the child and parent classes, and nowhere else: public class Parent { public static Parent Root = new…
Safron
  • 802
  • 1
  • 11
  • 23
2
votes
2 answers

how to transform an Array to an N-ary tree?

I have an Array that I need to transform it to an N-ary tree. I know the value of N, and the total number of nodes. I give you an example in the picture below. The N-ary tree should be ordered as illustrated. Link to image here I can't figure it…
Paul M.
  • 108
  • 1
  • 10
2
votes
3 answers

Packing tree into array in Javascript

Ok, so this shouldn't be difficult, however I have encountered weird and bizarra flukes. I am trying to pack a tree into an array, where each node is something like: title: string-for-display key: id-value children: array of child nodes the…
sarsnake
  • 26,667
  • 58
  • 180
  • 286
2
votes
0 answers

N-level tree structure in android implementation

I want to implement a N-level tree structure in android. I have gone through the ExpandableListView, but it is applicable for only 2 or 3 levels. My requirement is as below... CAR | |==Toyota | | | |==Sedan | | | | | …
Lakshman
  • 21
  • 2
2
votes
4 answers

Persistence: Data Trees stored as Directory Trees

I was wondering as to the practicalities of storing an in memory tree structure as directory tree for persistence purposes. In my case he target filesystem will be ZFS, and once the structure has been created it will be accessed by multiple…
Ande Turner
  • 7,096
  • 19
  • 80
  • 107