M
M
mr jeery2020-09-23 22:10:56
Algorithms
mr jeery, 2020-09-23 22:10:56

Algorithm to find a node in an unordered tree?

There is an unordered tree in which each node can have any number of children
. Is there an algorithm for finding a node by its key that does not require iterating through the entire tree?

When forming a tree, we can add arbitrary fields to each node

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmshar, 2020-09-23
@jeerjmin

In a NOT ordered tree, there is no such algorithm. This is no different from searching in a NOT ordered array. Both tasks require viewing the entire set of elements. When ordering - you can think about improving the efficiency of the algorithm.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question