N
N
nvdfxx2019-07-30 12:42:01
Algorithms
nvdfxx, 2019-07-30 12:42:01

Search all elements, how?

There is a parent element, it can have as many children as you like, these children can also have as many children as you like, and so on. How to loop through all the elements and write to an array? The PL is not important, even though the pseudocode. Recursively or not, there is no difference either, what is the fastest algorithm?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2019-07-30
@nvdfxx

Senior Pomidor developer

#!/bin/pomidor

функцыя всехпорву(аргумент, мешок){
    мешок.запихнуть(аргумент)
    длявсех(детей аргумента){
        всехпорву(детей, мешок)
    }
}

конкретный_мешок = []
всехпорву(конкретный_аргумент, конкретный_мешок)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question