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

Return smallest two numbers with negatives in Excel

If I have an array of numbers in Excel like below: -5 1 4 -2 I need to return -5 and -2 (each in a separate cell). The =SMALL(array, 1) does not work because the numbers in my array are less than 1. Is there a workaround so I can traverse…
Philip McQuitty
  • 1,077
  • 9
  • 25
  • 36
0
votes
1 answer

"Simple" jQuery traversal difficulty given multiple identical ID's (I know)

This should be simple but my mind has gone blank. Given I want to update the input#mirror-field when the input just above it in the markup changes - how can I target that "next" ID? Given (don't ask!) there are other inputs with the same ID on the…
mayersdesign
  • 5,062
  • 4
  • 35
  • 47
0
votes
1 answer

How to access and loop through an adjacency list?

Here is the implementation of my adjacency list used to form a graph. I have no idea how to access this list and loop through it to fulfill some goals (DFS search for instance). I tried to do something like graph[i][j] but the compiler would say…
2Xchampion
  • 666
  • 2
  • 10
  • 24
0
votes
1 answer

What notation to use when accessing an adjacency list?

I'm attempting to do a DFS search on a certain graph, here I have attempted to write down the following code (I'm aware that there are many errors/warnings and mistakes I have made but this is only a start and I need some help). int…
2Xchampion
  • 666
  • 2
  • 10
  • 24
0
votes
1 answer

R partykit calculate classification probabilities on sub stree

I have trained a partykit package ctree classification decision tree and I need to calculate classification probabilities for sub tree (not only for leaf nodes). So for example if a sub tree consists of 3 leaf nodes with the following…
NRG
  • 149
  • 2
  • 10
0
votes
1 answer

post-order traversal binary tree right to left

I know what the output would be when we traverse a binary tree with a post order algorithm from left to right, however I am having a bit of trouble seeing what it would be when we go from right to left. For example, would the output of a post order…
0
votes
2 answers

jQuery: nextEl = someEl.next(function() {... return true/false; })?

How can I get the nearest next element that sattisfies some condition/function? Like: nextEl = someEl.next(function() {... return true to return this from next() }); I'm not aware that the .next() method in jQuery API supports a function as an…
tillda
  • 18,150
  • 16
  • 51
  • 70
0
votes
1 answer

OCaml Binary Tree

Pass the function below through this Binary Tree: let rec inorder(t:tree) : int list = begin match t with | Empty -> [] | Node (left, x, right) -> inorder left @ (x :: inorder right) end Why is the result [1;2;3;4;5;6;7] and not…
user
  • 7
  • 4
0
votes
0 answers

Ways to enumerate a sequence of input data

There are a couple of ways to traverse and process a range of data, but when things get more complex, it becomes quite hard, too. If each operation is independent, life is easy: [1] modification for(auto&& x : v) x += 1; [2] access for(const…
0
votes
1 answer

Elegant traversal of a source in Scala

As a data scientist I frequently use the following pattern for data extraction (i.e. DB, file reading and others): val source = open(sourceName) var item = source.getNextItem() while(item != null){ processItem(item) item =…
EliG
  • 1
  • 2
0
votes
1 answer

What traversal will produce the output I need

I have a tree of nodes in this form: I need to be able to traverse the tree in order to produce the output: a / b + c The nodes labelled 'node' are for structure and I know which nodes are the ones which contain the correct values so the output can…
cookies
  • 347
  • 1
  • 6
  • 18
0
votes
2 answers

Why graph doesn't find correct path?

I've tried to create graph with the help of the following link but when I used find_path method I got incorrect path returned. Link: http://www.python-course.eu/graphs_python.php Code: class Graph(object): def __init__(self, graph_dict=None): …
Hsin
  • 307
  • 5
  • 15
0
votes
2 answers

Accessing a javascript object within a for loop returns undefined

I'm trying to access a nested javascript object within a for loop. The first level objects show up just fine, but the second level children show up as undefined. However if I do this outside a loop, hard-coding the object access, it works just fine.…
SoKeT
  • 590
  • 1
  • 7
  • 16
0
votes
0 answers

Column-wise matrix traversal in assembly

Disclaimer: I have absolutely no experience with assembly programming, hence this question. I want to write a program to traverse a matrix two ways, row-wise and column-wise, to demonstrate cache stuff for a presentation etc. The problem is, if I…
Elliot Gorokhovsky
  • 3,610
  • 2
  • 31
  • 56
0
votes
2 answers

Traverse nested Object Literal data

Been looking through the forums and none of the solutions that I have seen have worked for my case unless I am doing it wrong. I am trying to list out data for different states that is connected to a jQuery map plugin. Basically the user will click…