What tools can a tree structure be implemented with? Hierarchical model of the company: let's say there is 1 head, 3 managers and 7 employees. Is it possible to create a linked list of 3 cells, but such that in each element there is a corresponding number of necessary cells, something like a dynamic array?

  • Open the book Cormen "Algorithms" and look for trees. The only thing I will tell you is to use pointers to them instead of the objects themselves, so that you can change and add connections more easily and quickly. Actually, SO solves problems with the code, but you don’t even have a hint of it. - MrBin
  • What does SO mean? - Vitaliy Kitov
  • StackOverflow :) - MrBin
  • Yes, even vector<list>> :), but it is not clear what the deal with the tree structure is. It seems to me - you need to dance on the functionality, what you want to do with them. For example, they can all be derived from some kind of “employee” class, and an enterprise can be a collection of employees or something like that ... - Harry

1 answer 1

 struct Company{ std::string Chief_name; std::string manager_names[3]; std::string working_names[7]; }; int main() { std::list<Company> lst; // вводите в lst ваши обьекты Company return 0; }