1

I've faced this question and I hope that someone can help with it.

Question: We're given an undirected graph $G=(V,E,w)$ where $w\colon E\rightarrow \mathbb{Q}$ and vertex $v$. We want to find if there's an MST of $G$ such that $\deg(v)=2$, in other words there's 2 edges connected to $v$ in the MST.

Complexity requirement: Prim's Algorithm, in other words, $O(|E|+|V|\log |V|)=O(|E|)$.

I had many ideas for solutions but always found a bug in my solution, so if someone can suggest a solution using this complexity it'll be great.

Note: Kruskal's algorithm can't be used here since the graph is a general graph and Kruskal's complexity is worse than Prim's in the worst case.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
Mohamad S.
  • 449
  • 2
  • 12

0 Answers0