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

How to create a binary tree with the traversals given?

Okay, so say that we are given two lists: the pre-order traversal values of a binary tree, and the in-order traversal values given in a list. Now, I need to create a tree (in list form e.g. [1, [2, [2, None, None], None], [1, None, None]]). I can…
user3033494
  • 159
  • 1
  • 2
  • 6
0
votes
1 answer

Binary Tree Two Longesth Path's of Same Length

In a binary tree, how do you determine which path is the longest if you have two paths of the same length that are longer than the rest of the other paths? Essentially, no single path is the longest...do you just pick one of the paths or is it first…
user2499298
  • 177
  • 2
  • 5
  • 17
0
votes
2 answers

Print all the elements on a single given level of a binary tree

I am required to print out(visit) the nodes on a single level of a binary tree. I don't see how this can be done but then again I not very skilled with algorithms in general. I know that in Breadth-First traversal you use a queue and that you start…
Para
  • 2,022
  • 5
  • 34
  • 73
0
votes
1 answer

jQuery traversing up an unordered list / treeview

Im basically making use of the jquery treeview plugin http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ which does not have a search functionality - i solved that - but once i find the item i also have to open the whole treeview - and…
owsata
  • 1,105
  • 1
  • 11
  • 24
0
votes
2 answers
0
votes
2 answers

Iterate over nodes in a tree

I want to make an iterator that can handle my selfmade structs: struct node { int n; //data element node * parent; node * left; node * right; node (int elem): n(elem){ //create root parent = NULL; left = NULL; right = NULL; } node (int elem,…
user2321611
  • 1,049
  • 1
  • 7
  • 17
0
votes
1 answer

What is the logic for traversing each and every path in a binary tree in C++?

This is my first time i am studying binary trees, and i see a lot of questions regarding the path traversal, one such question was to find the path of a particular node. This is very easy in a Binary Search Tree, but it's very tough in a normal…
user3020666
  • 25
  • 1
  • 4
0
votes
1 answer

Dijkstra Traversal relationship property

Is it possible to search for the shortest path using Dijkstra from Node A to Node B by only passing nodes having a property x with a certain value? Is this also possible by taking a relationship property into account? If yes, could you explain me…
0
votes
4 answers

getting min and max height of a tree in one traversal of Binary tree in Java?

I have two methods to get min and max height of a binary tree in Java. But I am doing two traversals through the root two times. each is log n in Big(O). Is there a way to compute both min and max in same traversal and return as an array with two…
brain storm
  • 30,124
  • 69
  • 225
  • 393
0
votes
1 answer

Traverse a tree recursively and return an un-muted list of all values found? Possible?

I wonder if this is even possible at all as the question suggest. My problem is that I cannot seem to grasp how to handle the fact that a given input value can have multiple children. The problem is easily solved by using the mutable SortedSet…
jcd.no
  • 55
  • 1
  • 8
0
votes
1 answer

What am I doing wrong with in-order and post-order tree traversals

I'm working on practiceit trying to prepare for a test. I'm doing tree traversals now, an I thought I had a handle on them, but I've gotten to this question and I can't get the in order or post order traversals correct. The question is: Suppose…
insomnius1
  • 11
  • 1
  • 5
0
votes
1 answer

What is the next step for this tree according to morris inorder?

Just before I sat down to write code for morris inorder traversal I tried this example and am a bit confounded as to how its gonna work in this particular case: 80 / \ 60 100 \ / 70 90 / 65 / 63 …
0
votes
1 answer

tree traversal not giving expected output

I have this below simple code which is standard I believe for traversal. The problem is I'm getting expected output for a particular set of input, and unexpected for other. e.g. for input sequence 15,3,6,11,45,54,65,3,66 I am getting as expected…
0
votes
2 answers

jQuery addClass to 1st-3rd Matched Elements

BACKGROUND I've got a layout consisting of four absolutely-positioned div "quadrants", like so: div.quadrant#one | div.quadrant#two height: 25%; | height: 25%; width: 25%; | width: 25%; …
Marcatectura
  • 1,721
  • 5
  • 30
  • 49
0
votes
1 answer

Tree Traversal - Find between two leaves

I have a network node map, and I need to build a list of nodes between two points. It sounded simple enough to me at first, but the answer is eluding me :( Given the (simplified) data structure of: Id Name LeftId RightId 1 Skagway …
Dan Morphis
  • 1,708
  • 19
  • 23