DSC 40B – Theoretical Foundations of Data Science II
Problems tagged with "shortest path"
Problem #231
Tags: shortest path, graph theory
Suppose an undirected, connected graph has \(n\) nodes, half of which are colored red and the other half are colored blue. Each red node is neighbors with \(n/4\) blue nodes, and each blue node is neighbors with \(n/4\) red nodes. There are no edges between nodes of the same color.
What is the time complexity of computing a shortest path from a given red node to all other red nodes using BFS?
Solution
\(\Theta(n^2)\)