প্রতি নোড এর জন্য ২ করে মান বাড়ালে কিভাবে একি নোডের সাথে অ্যাড থাকা একাধিক নোড এ কিভাবে সে কাজ করবে, যদি আরেকটি উদাহরণ দিয়ে বুঝিয়ে দিতেন প্লিস।
@Algo-gr7xzАй бұрын
Please assume this example 1 2 1 3 Here, our node 1 and 2 are connected with one another. So, the node 1 will get 1 value and 2 get the value 2. Now, question is which value we will set for the node 3? We can set 5 at here. That's why our distance from parent to child is 4 at here. So, our a array is ;- 1 2 5 Here , what was our formula? We can increase the value's by 1 for a single depth of a source node. But in the case of the other connected node with that source will not applicable to this formula. To solve this we take decision to increase the value by 2 for each node. Now question is, does it will balance for all case? Let us consider the case we mentioned it above. here at the node 1 the value is x, then the below connected node 2 get the value x + 1 and also increase 1 value according to our formulla, so the node 3 now get the value x + 4. so the difference between two node is (x + 4) - x = 4. So this formula said us that we can generate distance always >= 4 at here. As our incrementor is always 2 at here, so the distance value we get this will be even in most of the case and which case it doesn't get even this will not prime number. For any query feel free to comment.