The problem is in the images. Please write this in Python. And you can skip the “input” step. Thank you.C++
Autocomplete Ready O
?
2. Connected Groups
1 > #include **
9
10 /*
11 * Complete the ‘countGroups’ function below.
12
13 * The function is expected to return an INTEGER.
14 * The function accepts STRING_ARRAY related as parameter.
15 */
*
16
Relationships between people may be
represented in a matrix as a series of binary
digits. For example, the direct relationships
for person with persons through 5 might
be shown as 101100. This means that
person Oknows persons 0, 2 and 3, the
indices of each of the 1 values. A relationship
is transitive. In other words, if person
Oknows person 2 and person 2 knows
person 3, then person Oknows person
3 through person 2. A group is composed of
all of the people who know one another,
whether directly or transitively.
17
int countGroups (vector related) {
18
19 }
20
21 > int main() ***
Example
Consider the following relationships matrix:
0 1
2
0
1
1
0
Line: 9 Col: 1
1 1 1
0
Test Results
Custom Input
Run
Submit Code
C++
Example
Consider the following relationships matrix:
Autocomplete Ready O
?
0 1
2
0
1
1
0
1 > #include ***
9
10 /*
11 * Complete the ‘countGroups’ function below.
12
13 * The function is expected to return an INTEGER.
14 * The function accepts STRING_ARRAY related as parameter.
15
*
1
1
1
0
2
0
0
1
16
17
int countGroups (vector related) {
18
Persons 0 and 1 are connected, while person
2 is not. There are 2 groups.
19 }
20
21 > int main() ***
Determine the number of groups
represented in a matrix.
Note: The method signatures may vary
slightly depending on the requirements of
the chosen language. For example,
language will have an argument that
represents the number of rows and columns
in the matrix. Also, Java will receive a list
rather than an array.
Line: 9 Col: 1
Function Description
Test Results
Custom Input
Run
Submit Code
carlataba function coutGrouacsta
Function Description
Complete the function countGroups in the
editor below.
C++
• Autocomplete Ready O
countGroups has the following parameter(s):
int related[n]: an array of strings of binary
digits related[i] that represent connections of
people
1 > #include ***
9 |
10 *
11 * Complete the countGroups’ function below.
12
*
13
14
* The function is expected to return an INTEGER.
* The function accepts STRING_ARRAY related as parameter.
*/
Returns:
int: an integer that represents the number
of groups of people
15
16
17
int countGroups (vector related) {
Constraints
18
19
}
20
21 > int main()
• 1sns 300
• Osi
Sample Case 0
C++
Autocomplete Ready O
Sample Input
1 > #include **
9
STDIN
Function
10
4
11
* Complete the countGroups’ function below.
size of related[] n = 4
related = [‘1100’, ‘111
12
*
1100
1110
0110
0001
13
14
* The function is expected to return an INTEGER.
* The function accepts STRING_ARRAY related as parameter.
*/
15
16
Sample Output
17
int countGroups (vector related) {
18
2
19 }
20
21 > int main() —
Explanation
Squares highlighting a connection
between two people are highlighted in
green. Each of the people is known to self,
so they are highlighted in gray.
related[ ]
1 2
0
3
0
1
1
0
0
Line: 9 Col: 1
1
1
1
1
0
Test Results
Custom Input
Run
Submit Code
C++
Autocomplete Ready O
(?
related[ ]
0 1 2
3
1 > #include **
9
0
1
1
0
0
1
1
1
1
0
*
2
0
1
1
0
3
0
0
0
1
10
11 * Complete the countGroups’ function below.
12
13 * The function is expected to return an INTEGER.
14 * The function accepts STRING_ARRAY related as parameter.
15 */
16
17 int countGroups (vector related) {
18
19 }
20
21 > int main()
The 2 groups formed are :
{related[0], related[1], related[2]}
and {related[3]}
There are n = 4 people numbered
related[0] through related[3).
There are 2 pairs who directly know each
another: (related[0], related[1]) and
(related[1], related[2]). Because a relation is
transitive, the set of people {related[O],
related[1], related[2]] is considered a single
group.
The remaining person, related[3], does not
know any other people and is a separate
group: {related[3]).
There are a total of 2 groups.
Line: 9 Col: 1
Test Results
Custom Input
Run
Submit Code

Purchase answer to see full
attachment




Why Choose Us

  • 100% non-plagiarized Papers
  • 24/7 /365 Service Available
  • Affordable Prices
  • Any Paper, Urgency, and Subject
  • Will complete your papers in 6 hours
  • On-time Delivery
  • Money-back and Privacy guarantees
  • Unlimited Amendments upon request
  • Satisfaction guarantee

How it Works

  • Click on the “Place Order” tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
  • Fill in your paper’s requirements in the "PAPER DETAILS" section.
  • Fill in your paper’s academic level, deadline, and the required number of pages from the drop-down menus.
  • Click “CREATE ACCOUNT & SIGN IN” to enter your registration details and get an account with us for record-keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
  • From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.