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

**-1**

votes

**0**answers

39 views

### Tree Traversal - Closest Common Parent

I'm writing a method to find the closest common parent between two nodes. I'm trying to iterate through the two different node's parents until I find a common parent node. The code below is traversing ...

**2**

votes

**3**answers

47 views

### Java generic tree traversal with node filtering

I have a generic tree structure.I need an algorithm to traverse it, and remove some leafs if they are not contained in a given list. If all the leafs are removed from a subtree, then remove the whole ...

**1**

vote

**1**answer

39 views

### Traversing a binary tree in level order in python

I have a python script that generate a binary tree for a given mathematical expression. I'm trying to write a function to print the binary tree if I traverse it in the level-order. e.g. if the ...

**2**

votes

**1**answer

53 views

### Does any traversal of a tree work any time?

This might be more of a theoretical (or mathematical) question:Given a finite tree, if I can do one operation (say, finding lowest common ancestor) using a post-order traversal of a tree, then is it ...

**0**

votes

**2**answers

47 views

### How to efficiently traverse recursive case-class trees

I want to create a macro that generates a recursive traversal of a tree of case class instances similar to the visitor pattern. The generated code should recurse for all fields whose type is derived ...

**0**

votes

**1**answer

70 views

### Haskell preorder traversal of binary tree

I'm trying to write a function that will traverse a binary tree and return a list of the integers encountered. My data Tree declaration is as follows:data Tree=Node Int Tree Tree | Leaf Int...

**0**

votes

**0**answers

33 views

### Given postorder and inorder traversal, get preorder traversal in Swift, dataStructure Algorithm

so I need to get preorder traversal by using given post and inorder traversal. here's my code in playgroundclass Node {var value: Intvar left: Node?var right: Node?init (value:...

**0**

votes

**1**answer

36 views

### SQL - Getting a single branch of a hierarchy

I have the following table "x" of hierarchical attributes:+-----------+--------+--------------+-----------+-------------+| row | value | displayvalue | parentrow | parentvalue |+-----------+...

**0**

votes

**1**answer

86 views

### What is the algorithm to traverse a non-binary tree without recursion (using stack) [duplicate]

Intuitively I understand that I keep on stack pairs like (node, iterator), but still I can not get to a working solution.

**-2**

votes

**1**answer

57 views

### python3 - traverse tree and get all sets of leaf node siblings

I have a json file and its structure is like a nested tree:{"sub": [{"code": "01","name": "a"},{"code": "02","name": "b","sub": [...

**0**

votes

**1**answer

42 views

### Haskell: Turtle: Managing Shell type

This a working snippet:import Turtle...groom :: FilePath -> IO ()groom src=doview (ls src)...I can see a list of paths on the console. Actually I'd like to have something like [...

**0**

votes

**0**answers

35 views

### Not able to traverse elements in Binary search tree in C++

I am trying to print all the elements using inorder traversal, but my code is giving incorrect output. I am not able to figure out what went wrong.#include <iostream>using namespace std;...

**0**

votes

**2**answers

66 views

### Traverse a Spaghetti Stack and reverse to a tree

I have a Spaghetti Stack (an N-ary tree data structure in which child nodes have pointers to the parent nodes) - received from a database.The "stack" received from database is just a list with all ...

**1**

vote

**1**answer

58 views

### Traversals for Java TreeMap

Is it possible to perform a pre-order traversal/in-order traversal/post-order traversal/level-order traversal on a TreeMap in Java without any additional classes or libraries?

**1**

vote

**3**answers

34 views

### Binary Tree: Method to return TRUE if all values equal a specific value

In Java, I'm working on coding a boolean method that traverses through an entire binary tree for a specific value (e.g. integer value 1) and if all the nodes are that value, the method returns true....