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
-3
votes
1 answer

Inconsistent append behavior in Go?

I'm writing a function that returns the vertical order traversal of a binary tree's node values. (ie, from top to bottom, column by column). Here's an example of expected input and output: Input: [3,9,8,4,0,1,7,null,null,null,2,5] (0's right child…
solo
  • 743
  • 2
  • 6
  • 17
-3
votes
1 answer

Read Values of specific array at specific XML node with PHP

Hello I am trying to list tour name in the 6 node of filter object. Formated xml image is also attached. This is my loop. foreach($results->filters->filter[6] as $key=>$tours){ foreach($tours as $tour_name){ echo…
-3
votes
1 answer

Given a Binary Tree print all paths that leads to a given sum (s)

Given a Binary Tree print all paths that leads to a given sum (s) . Note : In this problem the sum can be in part of left and right sub-tree as well. Path need not to start at root. Though i refer this question for help. Still i could not come up…
Abhay Kumar
  • 105
  • 1
  • 5
-3
votes
1 answer

Java binary tree postorder traversal recursively

// Trying to return a list containing the values in 'a' by traversing the nodes in postorder. In Junit it says that "String cannot be cast to List". Help please. public static List postorder(Tree a) { if (a.getEmpty()) return…
-3
votes
1 answer

program is running in between and halts at some places

#include #include struct node { int data; struct node *left; struct node *right; }; typedef struct node* LIST; LIST getnode(int dat) { LIST temp=(LIST)malloc(sizeof(LIST…
-4
votes
1 answer

binary tree traversal code explaination needed

I have a question on how this binary tree traversal code works. void BinaryTree_Functions::preorder(Binary_TreeNode* bt) { if (bt == NULL) { return; } cout << bt->data <Left); …
-5
votes
1 answer

Recursive and non-recursive traversal of three degree tree

I'm trying to write an algorithm for inorder traversal (left, node, mid, right) of a three degree tree. Is the below a correct algorithm for this? inorder(node) { if (node) { inorder(node->left); print("%d", node->value); if…
Vaibhav
  • 1
  • 3
1 2 3
55
56