Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement : There are 2 * N nodes in an undirected graph, and a number of edges connecting some nodes. In each edge, the

Problem Statement :
There are 2* N nodes in an undirected graph, and a number of edges connecting some nodes. In each edge, the first value will be between 1 and N, inclusive. The second node will be between N +1 and ,2* N inclusive. Given a list of edges, determine the size of the smallest and largest connected components that have or more nodes. A node can have any number of connections. The highest node value will always be connected to at least 1 other node.
Note Single nodes should not be considered in the answer.
Function Description
Complete the connectedComponents function in the editor below.
connectedComponents has the following parameter(s):
- int bg[n][2]: a 2-d array of integers that represent node ends of graph edges
Returns
- int[2]: an array with 2 integers, the smallest and largest component sizes
Input Format
The first line contains an integer n, the size of bg.
Each of the next n lines contain two space-separated integers, bg[ i ][0] and . bg[ i ][1]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions