Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя noob_master

Автор noob_master, история, 5 лет назад, По-английски

How to form a k-nary tree with x leaf nodes.
Is there any way to find whether a k-nary tree(every node has either k child or it is a leaf node) which have x leaf nodes exists or not. If exits then how to find it.

  • Проголосовать: нравится
  • -18
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Unless I’m missing something, you can make an arbitrary k-ary tree with any number of nodes.

»
5 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Work through a few small examples and look for a pattern that can be generalized.

  • »
    »
    5 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I asked the question after trying. Nevertheless, I will try again.

    • »
      »
      »
      5 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Let’s walk through some examples together.

      For any k, we can start with a k-ary tree of 1 node. Each time we want to go from a k-ary tree of a certain size to the one of the next smallest possible size, we will choose a leaf node and make it an internal node with k children (which are leaves).

      k=2
      k=3
      k=11

      ...

      Result