jeudi 21 novembre 2019

How to count the number of nodes of both sides of all edges in a tree

I wan't the solution for all edges, not for a single edge! I have applied BFS/DFS for every edges to calculate its nodes of one side but the complexity is very high. And I know that if I can find the nodes of one side, nodes of other side can be calculated by doing (n-(nodes of one side)).

Sorry for my bad English.

Aucun commentaire:

Enregistrer un commentaire