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
0 answers

Binary Tree Traversal adding empty values to trees

I am trying to recursively traverse a binary tree in preorder, inorder, and postorder. I have to return a list of the specified traversal, the code for preorder traversal is below: class EmptyValue: pass class BinaryTree: """Binary Tree…
dev_prabh
  • 53
  • 1
  • 5
0
votes
1 answer

Index out of bound exception when traversing a tree

I'm having problems with my mini filesystem I'm creating for a homework. The current assignment is to implement the operation find which basicly finds the folder or file with the name you send in. I't works when I'm traversing through it's parents,…
0
votes
2 answers

Higher order functions in tree traversal

How would I be able to create common tree operations such as insert and search while passing in functions to reduce redundancy. For example, a recursive function calls itself on the left branch when the value passed in is greater than the current…
0
votes
1 answer

List Traversal w/ temp pointer - Danger allocating node space referred to by the pointer when declaring the pointer?

This is part of a homework assignment, and the wording of the question is kind of confusing me. Say I want to traverse a list. I'll set a temporary pointer to the head of the list, and then I'll have it iterate from node to node until I reach the…
Victor
  • 57
  • 2
  • 8
0
votes
0 answers

Is comparing the strings of pre-order traversal of 2 trees with null nodes sufficient and necessary to determine if a tree is a subtree of another?

I have 2 binary trees, and the value of nodes are not necessary distinct. I want to determine if one tree is a subtree of another. Is comparing the strings of the pre-order traversal of 2 trees with null nodes sufficient and necessary (iff…
Cheng
  • 770
  • 11
  • 22
0
votes
1 answer

Java Tree traversal

I am working on an API in which, I generate a query based on conditions tree received in request. Following is the tree format: It should get translated in the SQL query like this: WHERE (a>b OR cf OR gb) OR…
user3968762
  • 439
  • 1
  • 5
  • 11
0
votes
1 answer

Error in printing BST traversal - Segmentation Faults

I am coding to print out BST preorder and postorder traversals. The class tree is defined like this class BinSearchTree{ char symbol; BinSearchTree *lChild; BinSearchTree *rChild; public: BinSearchTree(char letter) { symbol =…
0
votes
1 answer

JQuery Tree Traversal : mixing closest and siblings

I have structures that look like this :
Seeven
  • 969
  • 1
  • 8
  • 24
0
votes
2 answers

C++ design question on traversing binary trees

I have a binary tree T which I would like to copy to another tree. Suppose I have a visit method that gets evaluated at every node: struct visit { virtual void operator() (node* n)=0; }; and I have a visitor algorithm void visitor(node* t,…
user231536
  • 2,661
  • 4
  • 33
  • 45
0
votes
2 answers

How to remove path in tree starting from leaf?

I've got objects organized in a tree (not binary one). Every node has collection of its Children and Parent property. It is all presented in a TreeView already. I would like to click on the leaf and delete it in such a way that leaf is removed, it…
Dawid
  • 763
  • 1
  • 8
  • 17
0
votes
1 answer

jquery Tree Traversal prev() problem

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() { …
Guido Lemmens 2
  • 2,317
  • 5
  • 23
  • 29
0
votes
2 answers

Printing BST Formatted Output

I am trying to print a binary search tree and get the following output: -19->4->5->6->259-> How do I adjust the traverse function so that the last arrow is not printed in the output? I am using this code inside the main function: Tree x = new…
Rajan
  • 43
  • 7
0
votes
1 answer

DOM traversal in implementations of javascript getElementsByTagName

What method(s) of DOM (tree) traversal do implementations of the javascript function getElementsByTagName use? I ask because I'd like to be sure that the array returned by getElementsByTagName contains DOM elements in an order roughly from the top…
celeritas
  • 2,191
  • 1
  • 17
  • 28
0
votes
0 answers

Numerate tree nodes from linked list

I have the tree nodes connection info in the form of the linked list and ID of the root node. I need to numerate this nodes in such order that any lower level node in result should have higher number than any node of a higher level. Numbering starts…
nii
  • 189
  • 1
  • 14
0
votes
1 answer

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 = …
Chris
  • 483
  • 3
  • 14