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

Inorder traversal Printing Structure

I am working on a Binary search tree and right now I am working on having my inorder traversal be printed the way I want it to. I mostly figured it out but there is one tiny error in the way in which I want it to come out. Currently it prints out as…
0
votes
1 answer

StackOverflow exception in findPath method

I am trying to build the path for value in huffman, but I am getting stackoverflow exception. My code: public String findPath(short target, int root, String path) { String result; if (root < 0) { if ((result = findPath(target,…
Mindee
  • 11
  • 6
0
votes
1 answer

minimal edge representation of simple paths between all pairs of nodes

Honestly this doesn't seem as much of a graph type problem as it is a combinatoric/algorithm type question - but I did not know how to title it. The situation is this: I have a collection of nodes, which is a subset of all of the nodes of my…
Travis Black
  • 705
  • 7
  • 18
0
votes
0 answers

Iterator for AVL Tree with Removal and Insertion (C++ implementation)

I have implemented a template based AVL tree, and I'm struggling to implement an in-order iterator that comes with each tree that is robust with insertion and removal of elements. I'll include only a bit of the code given its length - please let me…
user8601366
0
votes
1 answer

Priority Queue not understanding how to trace the alogrithm

These are the instructions that I received... Insert the following n objects, in the order given, into a binary min-heap, you should trace the push method. 5, 3, 9, 7, 2, 4, 6, 1, 8 Apply the pop() method 3 times i'm not understanding how pop from…
Issajatt
  • 9
  • 5
0
votes
0 answers

Tree Recursion - Given a List, Update the Leafs with the Values in the List from Left to Right

Suppose I am given a list of values, say [13, 12, 15] and a tree of following with leafs 3, 2, 5. Following is my code to find each leaf from left to right and update the leaf value. Therefore, it is a postorder traversal. tree - tree with a…
Kevin Lu
  • 39
  • 6
0
votes
4 answers

jQuery: A shortcut to create a div container after a cue word

I'm creating a shortcut for a blog theme where I want to generate a div container around elements after using a cue word. For example, my blog entry would like this:

First Paragraph

[box]

Second…

Marc P
  • 606
  • 1
  • 11
  • 26
0
votes
1 answer

Attempting to traverse a quad tree to determine height

I'm currently trying to auto-generate a maze of randomly generated room objects that are linked via pointers in 4 directions - n, s, e, and w. I begin at Room *home, and build out with each new room having a 1/3 chance in creating a door in each of…
0
votes
1 answer

Jquery remove closest tr fail

I want to do the manipulation to remove the closest table when certain wording is exist at html. I cannot assume the span class will exist there, because the html is retrieved from other side, they may change it by adding, removing any class…
i need help
  • 2,386
  • 10
  • 54
  • 72
0
votes
1 answer

Traversing JSON in Haskell with wreq - key issues

I'm trying to traverse some JSON response I'm getting from the OpenWeatherMap API but I'm getting some issues to retrieve some values. Here is my code: {-# LANGUAGE OverloadedStrings #-} import Control.Lens import Data.Aeson.Lens (_String,…
David B.
  • 371
  • 5
  • 17
0
votes
1 answer

Chain Scala Futures when processing a Seq of objects?

import scala.concurrent.duration.Duration import scala.concurrent.duration.Duration._ import scala.concurrent.{Await, Future} import scala.concurrent.Future._ import scala.concurrent.ExecutionContext.Implicits.global object TestClass { final…
venus
  • 1,188
  • 9
  • 18
0
votes
1 answer

Traversing Expression tree

Is there any possibility to traverse Expression instance in .NET? I mean: i have Expression/Expresstion> instance generated in external code. is there any possibility to see what is in there ?
danyloid
  • 1,677
  • 3
  • 21
  • 47
0
votes
1 answer

How to get filepath from tree directory for reading lines of text files using wxpython..?

#!/usr /bin/python # -*- coding: utf-8 -*- import wx import os class RandomObj(object): def __init__(self, name): self.name = name class TreeExample(wx.Frame): def __init__(self): wx.Frame.__init__(self, None,…
0
votes
1 answer

Binary trie lexicological successor algorithm

I have binary trie (the nodes have values, but because it's a trie that doesn't matter for now) and I want to find the lexicological (by key, inorder) successor of given node. The node is implemented with parent, left and right pointers. I think the…
ValentaTomas
  • 260
  • 3
  • 11
0
votes
2 answers

Generic traversal of tree structure

I'm trying to write my tree (well, it's binary trie) traversal more generic, because the way it is now I have very similar code repeated. I'm walking the tree in lexicographical inorder. The example of functions I think can be abstracted by…
ValentaTomas
  • 260
  • 3
  • 11