Questions tagged [tree-traversal]

The process of visiting each node in a tree based on certain criterion.

The process of visiting each node in a tree based on certain criterion.

Use this tag for programming questions related to traversal of all types of trees.

See also:

832 questions
0
votes
1 answer

Getting JSON parent for node

Thank you all for your feedback as this is my first question. I'll try again. I have a JSON object as such: var obj = { "data":[ { "data":{ "title":"title1", "attr":{ …
0
votes
1 answer

Building a n-ary tree from a map

i was trying to build a tree out of a map, to show a class Hierachy with base classes and derrived classes. One node can have multiple children, and sub-children Here my code: std::map myClassMap; // 1. String (key) =…
user3126813
  • 57
  • 1
  • 7
0
votes
2 answers

jQuery Tree Up Traversal

Simple question. I'm trying to target the 'i' tag with the panel-indicator class in the tree. Additionally I need to remove the 'hide' class from the panel-edit 'i' tag. Here's the HTML:
Jason Tremain
  • 1,259
  • 3
  • 20
  • 35
0
votes
1 answer

Counting Nodes with single child in BST

i have this question : implement function int countSingle(), which uses Breadth-First Traversal (BFT) in order to count how many nodes in the tree have a single child. so the code below is what i thought of to solve it , is there another way of…
0
votes
2 answers

Unordered Binary Tree Traversal

For class, I have to create a binary tree of state objects, each of which includes a binary tree of resident objects organizing the people who live in each state. I'm trying to search a given state for its oldest resident; however, the residents are…
jiccan
  • 89
  • 12
0
votes
3 answers

How to traverse a binary tree and count the occurrence of a value without passing in a value

I am currently working on a program to implement a binary search tree. The struct for the tree is as follows: struct treeNode { Type value; int count; treeNode* left; treeNode* right; }; treeNode* root; I am trying to implement the…
Zack Herbert
  • 942
  • 1
  • 16
  • 39
0
votes
0 answers

AVL Tree traversals in JTextArea

public class AVLTree { public static String inorderTraversal = " "; private static void inorder(AVLNode btree) { if (btree != null) { inorder(btree.left); inorderTraversal += btree.value + " "; …
Jeremy
  • 113
  • 2
  • 14
0
votes
1 answer

Display ouput of AVL Tree traversals on multiple lines in JTextArea

for(int i=0; i < list.length; i++) { System.out.printf(" %2d",list[i]); // Formats right justified if ((i+1)%10==0) { System.out.println(); // Adds a new line after 10 values } } I'm trying to display the output of an AVL…
Jeremy
  • 113
  • 2
  • 14
0
votes
1 answer

Counting all nodes of all paths from root to leaves

If given a tree with nodes with integers: 1 ~ 10, and branching factor of 3 for all nodes, how can I write a function that traverses through the tree counting from root to leaves for EVERY paths So for this example, let's say it needs to return…
Charlie Baker
  • 81
  • 1
  • 2
  • 7
0
votes
1 answer

Why does xml.dom.minidom walk to remove empty text nodes work unexpectedly?

The Code: (usual depth-first) import xml.dom.minidom as xdom def _walk_n_apply(func, cond, parent): …
aniketd
  • 385
  • 1
  • 3
  • 15
0
votes
1 answer

Performant editing and traversing of a hierachical list

I'm having trouble editing fields/properties in a hierarchical list with the help of a second lookup list. Everything I try looks like a mess and is hard to maintain. Are binary search trees my friend? How would I apply them? Flattening my…
Dennis G
  • 21,405
  • 19
  • 96
  • 133
0
votes
2 answers

Finding deepest node in a tree (Lisp)

I am wanting to go through a tree in lisp and find the deepest (or furthest from the root node) by using a tree in the form of a list. So far my idea has been to keep on cutting the tree into left and right sub trees (assuming that the parent node…
justBecca
  • 133
  • 2
  • 13
0
votes
1 answer

Find the parent ID for every component which has an ID attribute

I am using JDK1.7, JSF2 and Primefaces. I have a .xhtml as below. I want to list the Parent and the Child Relations as following | | as shown in the Expected Output xhtml :
09Q71AO534
  • 4,300
  • 13
  • 44
  • 68
0
votes
1 answer

Recursion not fully traversing object with nested objects

I'm intending to write a module that can be instantiated with default configuration and then overridden with custom configuration when initialized. The configuration object has nested objects, so I need to traverse over these nested objects if they…
maxhallinan
  • 1,259
  • 2
  • 14
  • 28
0
votes
1 answer

algorithm for traversing multiple tables for a query

I am trying to write an algorithm which will help me to find the best path through multiple tables to fetch data for a query. The tables have overlapping variables which relate them to each other. For example, I may have a query like this: 'select…
mjpablo23
  • 681
  • 1
  • 7
  • 23