Questions tagged [traversal]

Traversal is the action of iterating over all the elements in a sequence of elements.

Traversal, in the context of programming languages, usually refers to the act of visiting all the elements in a sequence of elements - be it an array, a set, a list, or any other data structure.

Examples: Tree Traversal

2003 questions
0
votes
2 answers

Minimal difference between biggest and smallest value in any path of x length in matrix

I have a kattis task that I'm struggling with to complete. The task is to "find a set of at least k connected entries in a matrix, such that the difference between the largest and smallest entry in the set was minimized". The input is first the size…
J. doe
  • 17
  • 2
0
votes
0 answers

Preorder tree traversal using postorder + inorder

Hello I'm working on printing preorder tree traversal only having inorder and postorder traversal. Code to do that looks like : public static void preorder( int inorder[], int inostart, int postorder[], int poststart, int length) { …
user7807288
0
votes
1 answer

Vertical order traversal of binary tree

I am trying to perform Vertical order traversal of binary tree as follows: 1) Finding out the minimum and maximum horizontal distance of each nodes from the root node 2) Creating a hashmap that maps horizontal distances to corresponding…
0
votes
2 answers

intersection of two set of nodes (neo4j cypher traversal path)

I have a graph of 100000 nodes connected to each other by a relation. From a point A to a point B, there is only one possible path, no loop is possible in my model. I am looking for a solution that will indicate whether the path of a list of nodes…
gsaad
  • 1
  • 2
0
votes
1 answer

jQuery find two types of children elements

I have a checkbox which toggles elements under
and I am trying to apply readonly to inputs and readonly to selects and buttons, how can I achieve that in on jQuery statement? How can I make jQuery find twice with the same selector? …
Broshi
  • 3,334
  • 5
  • 37
  • 52
0
votes
1 answer

TURN Server Nat traversal ICE STUN

I am implementing a TURN server and I am going to use TURN rfc5766 terminology in my question. There is a part that I do not get. Lets say we have a client(A) who is connected to the TURN server and a peer(B) who is not connected to anything yet. …
Evren Bingøl
  • 1,306
  • 1
  • 20
  • 32
0
votes
1 answer

Traversing the complete array even after finding the string

i'm trying to traverse through the whole array till the end looking for the particular element even if it is found, till yet it is working till it is found for the first time. Like i have an array named a = [a,b,c,d]//(prodname) and other array of…
Shahtaj Khalid
  • 31
  • 1
  • 11
0
votes
3 answers

How can traversing through a (bit-)map be implemented more elegantly?

In general: How can traversal offsets be implemented and used more efficiently? Let's say we have a bitmap defined below. How could we traverse through (in this case collect) all nearby pixels starting from a fixed pixel - and ultimately avoid these…
Jar
  • 3
  • 3
0
votes
2 answers

Java indentation in Level-order Tree print, not binary tree

I want to print my non-binary tree with level-order traverse. In the code below I indent every time a new set of children has been added, but somehow I need to remove indentations when I go back in the tree again. Here's how this tree prints: Root …
0
votes
2 answers

Breadth first search binary search tree javascript implementation

I have the following code that implements a BST tree in JavaScript. function Node(value) { this.left = null; this.right = null; this.value = value; } function BinarySearchTree() { this.root = null; …
0
votes
2 answers

Recursive DFS Ruby method

I have a YAML file of groups that I would like to get into a MongoDB collection called groups with documents like {"name" => "golf", "parent" => "sports"} (Top level groups, like sports, would just be {"name" => "sports"} without a parent.) We are…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
0
votes
1 answer

How to write a method taking argument BinaryTree that uses preorder traversal to calculate X?

I can't for the life of me figure this out and was really someone could help me please, it's for revision purposes for an upcoming exam in Java: • The following interface specifies the binary tree type. interface BinaryTree { boolean…
0
votes
1 answer

Traversing Through a 2D Array diagonally from all sides

I'm currently working on N Queens problem where the input will be the size of the 2D array and the actual values of the 2D array. This code will check wether or not this input is valid, as in there aren't any other queens attacking each other, or if…
0
votes
1 answer

Could someone tell me why the binary tree I am creating in this code using it's preorder and postorder is not being created in the desired way?

I have written this code to create a binary tree using given preorder and inorder traversals. According to the dry run I do, there is no problem, and the tree should be created properly. But it is not happening that way. I have printed the inorder…
0
votes
2 answers

Python - k-ary tree list-representation pre- and postorder traversal

I'm creating a python class for a tree in which each node has n children (but each child only has one node). I need to implement two methods, pre-order and post-order. I'm stuck on pre-order. This is what I have so far: class KTree: def…
Nicole R
  • 3
  • 3