need in C++...asap
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
need in C++...asap
![Given a graph of friends who have different interests, determine
which groups of friends have the most interests in common. Then
Explanation 0
Node pair (2,4) shares only 1 interest (4) and node pair (1,3) shares 1
interest (3).
v Input Format for Custom Testing
use a little math to determine a value to return.
• Node pair (1,2) shares 2 interests (interests 2 and 3) and node pair (2,
3) shares also 2 interests (interest 1 and 3). So, the maximum
Each pair of
friends_nodes = 4
friends is connected by
the following interests:
Input from stdin will be processed as follows and passed to the
function.
The graph will be represented as a series of nodes numbered
consecutively from 1 to friends_nodes. Friendships have evolved
based on interests which will be represented as weights in the
graph. Any members who share the same interest are said to be
connected by that interest. Once the node pairs with the maximum
number of shared interests are determined, multiply the
friends_nodes of the resulting node pairs and return the maximal
product.
number of shared interests is 2.
• Multiply the friends_nodes of the resulting node pairs : 1 x 2 =2 and .
x 3 = 6.
The first line contains two space-separated integers friends_nodes
and friends_edges.
Each of the next friends edges lines contains three space-
separated integers, friends_from[i), friends_to[i] and
friends_weight[i] where 0si< friends_edges.
• The maximal product is 6.
Function Description
Pair (1, 2) shares 2
Complete the function maxShared in the editor below.
interests (i.e.,
(2)
Example
interests 1 and 2)
friends_nodes = 4
v Sample Case 0
maxShared has the following parameter(s):
3
friends_edges = 5
friends_from = [1, 1, 2, 2, 2]
friends to = [2, 2, 3, 3, 4]
friends_weight = [2, 3, 1, 3, 4]
Pair (1, 3) shares 1
int friends_nodes: number of nodes
interest (i.e., interest
int friends_from[friends_edges]: the first part of node pairs
int friends to[friends_edges]: the other part of node pairs
int friends_weight[friends_edges]: the interests of node pairs
Sample Input 0
1)
STDIN
Function
Pair (1, 4) shares 0
1
From
To
Returns:
interests
2
45
friends_nodes = 4
friends_edges = 5
The pairs connected by the
maximal number of interests are
3
int: maximal integer product of all node pairs sharing the most
Pair (2, 3) shares 2
interests.
1 2 1
friends from = [1,1,2,2,2] friends to = [2
3
interests (i.e.,
2
3
1 2 2
2 3 1
(1, 2) and (2, 3). Their respective
products are 1 x 2 = 2 and 2 x 3 =
6. The result is the the largest of
4
4
interests 1 and 3)
Constraints
2 33
Pair (2, 4) shares 1
• 2s friends_nodes s 100
2 4 3
interest (i.e., interest
The graph shows the following connections:
• 1 friends_edges s min(200, (friends_nodes x (friends_nodes - 1)) a
these values which is 6.
3)
1 s friends_weight[i] s 100
• 1 s friends_from[i], friends_to[i] s friends_nodes
• 1s friends_weight[i] s friends_edges
• friends_from[i] # friends_to[i]
Weight
(Interest)
Pair (3, 4) shares 1
Connectons
Sample Output 0
2,3
interest (i.e., interest
2
1,2
3)
1,2,3
• Each pair of friends can be connected by zero or more interests.
4
2,4
2.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F374717b5-b13c-4b50-9274-da57b0f4f9dc%2Ffdbda2a2-7207-4d70-b9b8-1bd7c3a801f3%2Fpkc4iv_processed.png&w=3840&q=75)
Transcribed Image Text:Given a graph of friends who have different interests, determine
which groups of friends have the most interests in common. Then
Explanation 0
Node pair (2,4) shares only 1 interest (4) and node pair (1,3) shares 1
interest (3).
v Input Format for Custom Testing
use a little math to determine a value to return.
• Node pair (1,2) shares 2 interests (interests 2 and 3) and node pair (2,
3) shares also 2 interests (interest 1 and 3). So, the maximum
Each pair of
friends_nodes = 4
friends is connected by
the following interests:
Input from stdin will be processed as follows and passed to the
function.
The graph will be represented as a series of nodes numbered
consecutively from 1 to friends_nodes. Friendships have evolved
based on interests which will be represented as weights in the
graph. Any members who share the same interest are said to be
connected by that interest. Once the node pairs with the maximum
number of shared interests are determined, multiply the
friends_nodes of the resulting node pairs and return the maximal
product.
number of shared interests is 2.
• Multiply the friends_nodes of the resulting node pairs : 1 x 2 =2 and .
x 3 = 6.
The first line contains two space-separated integers friends_nodes
and friends_edges.
Each of the next friends edges lines contains three space-
separated integers, friends_from[i), friends_to[i] and
friends_weight[i] where 0si< friends_edges.
• The maximal product is 6.
Function Description
Pair (1, 2) shares 2
Complete the function maxShared in the editor below.
interests (i.e.,
(2)
Example
interests 1 and 2)
friends_nodes = 4
v Sample Case 0
maxShared has the following parameter(s):
3
friends_edges = 5
friends_from = [1, 1, 2, 2, 2]
friends to = [2, 2, 3, 3, 4]
friends_weight = [2, 3, 1, 3, 4]
Pair (1, 3) shares 1
int friends_nodes: number of nodes
interest (i.e., interest
int friends_from[friends_edges]: the first part of node pairs
int friends to[friends_edges]: the other part of node pairs
int friends_weight[friends_edges]: the interests of node pairs
Sample Input 0
1)
STDIN
Function
Pair (1, 4) shares 0
1
From
To
Returns:
interests
2
45
friends_nodes = 4
friends_edges = 5
The pairs connected by the
maximal number of interests are
3
int: maximal integer product of all node pairs sharing the most
Pair (2, 3) shares 2
interests.
1 2 1
friends from = [1,1,2,2,2] friends to = [2
3
interests (i.e.,
2
3
1 2 2
2 3 1
(1, 2) and (2, 3). Their respective
products are 1 x 2 = 2 and 2 x 3 =
6. The result is the the largest of
4
4
interests 1 and 3)
Constraints
2 33
Pair (2, 4) shares 1
• 2s friends_nodes s 100
2 4 3
interest (i.e., interest
The graph shows the following connections:
• 1 friends_edges s min(200, (friends_nodes x (friends_nodes - 1)) a
these values which is 6.
3)
1 s friends_weight[i] s 100
• 1 s friends_from[i], friends_to[i] s friends_nodes
• 1s friends_weight[i] s friends_edges
• friends_from[i] # friends_to[i]
Weight
(Interest)
Pair (3, 4) shares 1
Connectons
Sample Output 0
2,3
interest (i.e., interest
2
1,2
3)
1,2,3
• Each pair of friends can be connected by zero or more interests.
4
2,4
2.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY