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...
icon
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.
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY