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
245
votes
5 answers

jQuery find parent form

i have this html
kmunky
  • 15,383
  • 17
  • 53
  • 64
180
votes
18 answers

List directory tree structure in python?

I know that we can use os.walk() to list all sub-directories or all files in a directory. However, I would like to list the full directory tree content: - Subdirectory 1: - file11 - file12 - Sub-sub-directory 11: - file111 …
cinny
  • 2,292
  • 3
  • 18
  • 23
156
votes
5 answers

How can I find the closest previous sibling with class using jQuery?

Here's the rough HTML I get to work with:
  • // this is the single element I need to select
  • daulex
    • 1,615
    • 2
    • 12
    • 10
    120
    votes
    13 answers

    Find all occurrences of a key in nested dictionaries and lists

    I have a dictionary like this: { "id": "abcde", "key1": "blah", "key2": "blah blah", "nestedlist": [ { "id": "qwerty", "nestednestedlist": [ { "id": "xyz", …
    Matt Swain
    • 3,827
    • 4
    • 25
    • 36
    115
    votes
    5 answers

    Can someone explain the traverse function in Haskell?

    I am trying and failing to grok the traverse function from Data.Traversable. I am unable to see its point. Since I come from an imperative background, can someone please explain it to me in terms of an imperative loop? Pseudo-code would be much…
    Konan
    • 1,151
    • 2
    • 8
    • 3
    73
    votes
    11 answers

    Jquery how to find an Object by attribute in an Array

    Given I have an array of "purpose" objects: //array of purpose objects: var purposeObjects = [ {purpose: "daily"}, {purpose: "weekly"}, {purpose: "monthly"} ]; (for simplicity i am omitting other attributes) Now I want to have a method…
    Jesper Rønn-Jensen
    • 106,591
    • 44
    • 118
    • 155
    70
    votes
    30 answers

    Post order traversal of binary tree without recursion

    What is the algorithm for doing a post order traversal of a binary tree WITHOUT using recursion?
    Patrik Svensson
    • 13,536
    • 8
    • 56
    • 77
    62
    votes
    4 answers

    Iterative DFS vs Recursive DFS and different elements order

    I have written a recursive DFS algorithm to traverse a graph: void Graph::DFS(Node n) { std::cout << ReadNode(n) << " "; MarkVisited(n); NodeList adjnodes = Adjacent(n); NodeList::position pos = adjnodes.FirstPosition(); …
    JohnQ
    • 1,073
    • 2
    • 10
    • 17
    61
    votes
    7 answers

    How to select all content between two tags in jQuery

    I have a document with headings and unordered lists. How can I use JQuery to select a given heading (by its unique class name) AND all content between that heading and the next heading? Update: Your suggestions are great, but aren't what I'm looking…
    edt
    • 22,010
    • 30
    • 83
    • 118
    60
    votes
    3 answers

    An example of a Foldable which is not a Functor (or not Traversable)?

    A Foldable instance is likely to be some sort of container, and so is likely to be a Functor as well. Indeed, this says A Foldable type is also a container (although the class does not technically require Functor, interesting Foldables are all…
    Prateek
    • 2,377
    • 17
    • 29
    51
    votes
    8 answers

    Iterating over element attributes with jQuery

    I know individual attributes can be retrieved with the attr() method, but I'm trying to iterate over all of the attributes for an element. For context, I'm using jQuery on some XML...
    theraccoonbear
    • 4,283
    • 3
    • 33
    • 41
    50
    votes
    10 answers

    Write a non-recursive traversal of a Binary Search Tree using constant space and O(n) run time

    This is not homework, this is an interview question. The catch here is that the algorithm should be constant space. I'm pretty clueless on how to do this without a stack, I'd post what I've written using a stack, but it's not relevant anyway. Here's…
    user183037
    • 2,549
    • 4
    • 31
    • 42
    47
    votes
    5 answers

    Quicker to os.walk or glob?

    I'm messing around with file lookups in python on a large hard disk. I've been looking at os.walk and glob. I usually use os.walk as I find it much neater and seems to be quicker (for usual size directories). Has anyone got any experience with…
    joedborg
    • 17,651
    • 32
    • 84
    • 118
    44
    votes
    6 answers

    How can I traverse/iterate an STL map?

    I want to traverse an STL map. I don't want to use its key. I don't care about the ordering, I just look for a way to access all elements it contains. How can I do this?
    atoMerz
    • 7,534
    • 16
    • 61
    • 101
    42
    votes
    3 answers

    jquery find next element with class

    I'm trying to find the next element with a class of "error" and hitting a wall. In looking at the demo on jQuery's site, this should work, but doesn't. $("button[disabled]").next().text("this button is disabled");
    Loony2nz
    • 4,691
    • 6
    • 28
    • 31
    1
    2 3
    99 100