This question is very similar to this one: spanning tree with exactly k colored edges
It's not the same question! - As you can see the answer of the question above is not the same (to my Q)....
We have a connected, undirected graph G=(V,E) with edges that are each either red or blue.
We know that |V|=n. We get two numbers: a1,a2āN where a1 is for the red edges, and a2 is for the blue edges. a1+a2=nā1.
We have to find an algorithm that checks if there is a spanning tree that have exactly a1 red edges and a2 blue edges. If not, the algorithm returns that there is no spanning tree with this condition.
I tried to get help from the question mentioned above, but I am still stuck. I assume these are very similar questions.