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

Dfs,Bfs, Order issues in Tree traversal

I have a difficulty in understanding the differences between dfs, bfs, and in-order, pre-order and post-order in tree traversal (binary tree). My understanding that dfs is neither pre-order, in-order or post-order Bfs is also neither pre-order,…
0
votes
0 answers

How does DB engine traverse down the clustered and non-clustered tables?

I'm trying to understand how SQL Server 2014 works while it's trying to find records in a table with clustered index or in a table with non-clustered indexes. There are two great figures in the following pages demonstrating the tree…
enesanbar
  • 49
  • 7
0
votes
1 answer

Quick Huffman Tree example

I was wondering if it mattered the direction of a huffman tree. Like if the problem was construct a huffman tree for A B C D E and theres a number given for each. Does it matter if I start from the top and then go down to the bottom in terms of…
0
votes
1 answer

How to print out a binary tree in order?

I'm struggling with the printing of a binary tree that I coded. It's a little program where you can type in different states and then it orders them alphabetically in the binary tree and afterwards it should print them out again, in alphabetic…
dave
  • 117
  • 2
  • 3
  • 13
0
votes
0 answers

How to find nodes fast in an unordered tree

I have an unordered tree in the form of, for example: Root A1 A1_1 A1_1_1 A1_1_2 A1_1_2_1 A1_1_2_2 A1_1_2_3 A1_1_3 A1_1_n …
Amc_rtty
  • 3,662
  • 11
  • 48
  • 73
0
votes
1 answer

Postorder traversal to Levelorder and finding the level of a node

I'm looking for a method or pseudo code to find the level of a particular node (the level in a level-ordered tree) which is written in post order string. I also appreciate any algorithm to convert a postorder string to level-order tree. I should…
Hirad A
  • 23
  • 3
0
votes
2 answers

BST Level Order Traversal list.clear() and list = new ArrayList

Context: I created a BinarySearchTree class in Java as a learning exercise since I'm new to Java. I'm currently writing a method for a level-order traversal (BFS) that returns a list of lists of node values for each level, where the top-level list…
0
votes
1 answer

GIven a level order FInd BST

Given a BST whose level-order traversal is: 99 65 53 80 22 62 98 21 49 82 36 51 what will be the tree if we make tree from the following level order traversal?
0
votes
1 answer

Python: Build Binary Tree with Pre and Inorder

I need help completing the recursive part of my function. The function is supposed to use my ListBinaryTree Class to help reconstruct a tree given its inorder and preorder traversal in string format: eg. preorder = '1234567' inorder = '3241657'…
Newbie
  • 378
  • 2
  • 12
  • 23
0
votes
2 answers

Python HTML Parser and Navigator

It's been a long while since I've worked with Python and I'm working on a small project where I need to be able to essentially locate an element as well as traverse the tree. Below is a JavaScript snippet of what I need to be able to do in Python. I…
Spedwards
  • 4,167
  • 16
  • 49
  • 106
0
votes
1 answer

Binary Search Tree - In-order Traversal

I am trying to make a crossword puzzle program utilizing BST's, i currently have the following words inserted into the tree: word, will, wyr, wale, wilt, apple, abs, wack(inserted in that order) but everytime i debug the program in visual studio, i…
StingRay21
  • 342
  • 5
  • 15
0
votes
3 answers

Python two recursion calls - shared instance of argument

I am trying to go through all the possible paths of a 2D matrix (conditions being that I can only go down or right). Here is what I am trying: rows = 3 columns = 3 # Class definition for node of the tree class Node(object): def __init__(self): …
Ishan
  • 3,303
  • 5
  • 29
  • 47
0
votes
3 answers

How to handle callbacks in JavaScript within recursive functions?

Trying to compare two sub trees of bookmarks in Chrome, I ran into troubles with the asynchronous API call to query the children of a bookmarks folder. function titleComparator (lhs, rhs) { return lhs.title < rhs.title ? -1 : lhs.title > rhs.title…
danijar
  • 32,406
  • 45
  • 166
  • 297
0
votes
3 answers

Problems with in-order tree traversal

I found this picture at Wikipedia: According to the text underneath the picutre, the in-order is: A, B, C, D, E, F, G, H, I I understand the order A-F, but what I don't understand is the order of the last three nodes. Is it not supposed to be H, I,…
Ali Mustafa
  • 475
  • 1
  • 6
  • 13
0
votes
1 answer

Traverse Object and build Tree Lineage

Json Object : var json = { "Tree": [{ "Title": "Condition", "Attr": { "Id": 2258, "Zone": null }, "Children": [{ "Title": "General Wellness", "Attr": { …
Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109