Questions tagged [n-ary-tree]

31 questions
0
votes
1 answer

Dart : N-ary tree implementation

I have a university project where I need to implement an N-ary tree in dart. This is my node so far class Node { Node parent; // parent of the current node List children; // children of the current node int id; String…
Devon L
  • 3
  • 1
0
votes
1 answer

Build n-ary tree from txt file

I'm doing a homework for university. Is the first time I use tree as a data structure and I don't understand how to implement it in Java. I have to read from a .txt file a string like this ( 1 ( 2 ( 5 ( 13 ) 6 7 ) 3 ( 8 9 ) 4 ( 10 11 12 ) ) ) where…
giasco
  • 1
  • 2
0
votes
1 answer

Create a k-ary tree from a list of coordinates and list of edges connecting them.

I have a list of Nodes/Vertices, and a list of lines/edges connecting these nodes.The lists are not sorted or ordered in any way, but contain all the edges and nodes for a particular data set. The edges are line segments defined by Cartesian…
0
votes
0 answers

Data structure, tree, n-ary tree, DFS

I am solving a simple question based on n-ary tree. Question is simple, finding total number of hand shaking between soldiers where each node of tree represents soldiers. Only ancestors nodes can…
0
votes
1 answer

N-Ary Tree C++ - How to find the level of a node

I would like to returns the level of a given node. I've been able to do this for binary trees but for n-ary trees there is no way to run it. Any ideas ? For the binary tree the solution was: int findLevel(BinAlbero::node root,…
0
votes
1 answer

number of nodes for a level in a first child - next sibling tree

I have to write a function to find the number of nodes in a level of a first child - next sibling N-ary tree. My function is: int nodesAtLevel(NTree root, int level) { if (root == NULL) { return 0; } if (level == 0) { …
J.D.
  • 105
  • 6
0
votes
1 answer

Find element in a n-Ary tree

Given the following structure struct nNode { int val; struct nNode parent; struct nNode children; struct nNode next; struct nNode prev; }; Where the children points to first child and to traverse to the other childs we need to…
Lin
  • 966
  • 6
  • 20
0
votes
1 answer

get path to the children from parent

I have a list of children and a list of parents. I also have a map of childeId-parentId. Parents can have n number of children but children have one immediate parent. I want to get the path to each child from parent in Java. How can I do it…
Akshay Talathi
  • 63
  • 2
  • 13
0
votes
1 answer

Python - Flat list tree implementation: Given child, get parent?

I'm creating a python class for a tree in which each node has a number of children given by "order" (but each child only has one node). I have a method, children(self,i), which returns the children of a node at index i. I need to implement…
Nicole R
  • 3
  • 3
0
votes
1 answer

Source for studying data structures

Does anybody know a good source where to study data structures? In particular i am looking for trees and graphs. I've already tried geekforgeeks but i wonder if there is something else as good as it. Thank's.
J.D.
  • 105
  • 6
0
votes
0 answers

How to visualise java n-ary tree

I would like to know if there is a way to visualise non binary tree in this way : the root to be at the top, its children under and so on .. It is important the children to be connected (with lines may be) to their parents. The visualisation may be…
0
votes
1 answer

Gnome N-ary Trees usage in c++

I'm trying to implement an N-ary Tree in c++ using the glib, but as I'm not a c++ expert, I'm having some problems finding out how to use it right. Does anybody have a simple example written in C++ to help me understand how to use the basic…
0
votes
1 answer

How to reparent using tree.hh

Here I have a window with a list of groups of rows. In the image above, Path 2 to 6 are children of Group1. http://i.stack.imgur.com/zb4FB.png The container used for this tree is tree.hh. What function would I use to make Group1 (and its children)…
-1
votes
4 answers

Data structures get maximum value at each level of N-ary tree

Lets say I have a n-ary tree something like below I need to find maximum value at each level and return like : [8,7,32] . 8 4 3 7 1 4 3 3 5 6 7 12 32 3 1 My Node will look…
sidkool3k
  • 43
  • 9
-1
votes
1 answer

C - deleting n-ary tree nodes

I have implemented in C an m,n,k-game with AI. The game works fine but when I have to free the decision tree it always throws an "Access violation reading location" exception. This is the implementation of the decision tree structure: typedef…