Answer the question
In order to leave comments, you need to log in
How to build an N-tree and find the longest branch without branches?
Good day.
According to the basics of programming, they set a task, the solution of which I can’t think of in any way, maybe someone can tell you how to do it or at least in which direction to drip / look for documentation: you need to build an N-tree and find the longest branch without branches.
This problem needs to be solved using c/c++.
Thanks in advance for the replies.
Answer the question
In order to leave comments, you need to log in
Something like
максРазмер : целое
началоМаксВетви: узел
проц максВетвь(узел : Узел, началоВетви: Узел, текРазмер: целое)
в зависимости от степени узла «узел»
если 0:
если текРазмер > максРазмер
максРазмер = текРазмер
началоМаксВетви = началоВетви
если 1: максВетвь(единственныйCын, началоВетви, текРазмер + 1)
если 2+:
для всех сыновей
максВетвь(сын, сын, 1)
максВетвь(корень, корень, 1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question