Given a set of nodes and a list of connected pairs, determine the order (number of nodes) in each connected component in the graph. For each component, calculate the ceiling of the square root of its order, and return the sum of these values across all connected components.
There are graph_edges = 5 ed
ges to consider. There are 2 isolated sets with more than one node: {1, 2, 3, 4, 5} and {7, 8}. The ceilings of their square roots are: √5 ≈ 2.236 and ceil(2.236) = 3 √2 ≈ 1.414 and ceil(1.414) = 2
The other three isolated nodes are separate, and the square root of their orders is √1 = 1 respectively. The sum is 3 + 2 + (3 * 1) = 8.
Function Description Complete the function `connectedSum` in the editor below. connectedSum has the following parameter(s): - int graph_nodes: the number of nodes - int graph_from[graph_edges]: an array of integers that represent one end of an edge - int graph_to[graph_edges]: an array of integers that represent the other end of an edge
Returns: - int: an integer that denotes the sum of the values calculated