How to calculate the ways to paint a tree?

Question!

How to calculate the ways to paint a tree's nodes with m colors so that the ends of each edge have different colors?

Any polynomial solution is welcome.



Answers

You have m choices for the root. If you paint going down from the root, you have m-1 choices for each additional node. If the number of nodes is n, then the number of ways to paint the tree is m * (m-1)^(n-1).



Always try to store datetime in milisecond so you can convert that in specific timezone. And you can use varchar and string(in laravel) to store it.

By : A.D


You can use datetime and timestamp both. better go for datetime data type that's good for retrieving.



This video can help you solving your question :)
By: admin