C
C
ccc352015-10-03 18:33:23
C++ / C#
ccc35, 2015-10-03 18:33:23

How to insert an ordered array into the nodes of a binary tree?

It is necessary to insert an ordered array into each node of a balanced ordered binary tree. Tell me how this can be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2015-10-04
@Mercury13

It's a little unclear what you need it for. If this is a training code, then write in a student way. In production code, I would use proven features as much as possible. The array is std::vector, the sort tree is std::set/std::map.
A balanced ordered binary tree needs a key by which it orders. There are two options.
1. Key - something with a natural comparison, for example, int. Then std::map<int, std::vector<int> >.
2. The key is the same array. Then std::set<std::vector<int> >. (In the previous version, I explicitly wrote a comparison mechanism, it turns out that it already exists and you don’t need to write anything!)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question