Question
Q1 Consider the LinkedIn solution that allows people to connect on a social media platform for employment purposes. Every user on LinkedIn can establish one
Q1 Consider the LinkedIn solution that allows people to connect on a social media platform for employment purposes. Every user on LinkedIn can establish one or more connections with other users on the same platform. In addition to the connections, assume that LinkedIn also tracks and saves the employer company of each user. Consider the following example. The above example shows that Khaled works for Roya and is connected to 4 other LinkedIn users: Ahmad, Sara, Sultan, and Firas. Write a function that allows a user to discover how connected he/she is to some company. The function targets a specific input company and prints how far the user is in his connections from that company, and how many users he is connected to from that company at that level. For instance, if Khaled likes to know how much he is connected to the STS company, the answer will be 2 (for the shortest distance to STS) and 2 (for the number of users at that distance working at STS). Another example, if Khaled likes to know how much he is connected to PSUT, the answer will be 1 for the distance and 2 for the number of users, as two users are directly connected to him from PSUT (Sara and Firas) Input N for the number of users, C for the number of connections between these users An array for the names of the users with names[0] as the name of the first user and so on. An array for the companies with companies[0] as the company of the first user and so on. An array of integers for the From values of the connections, assuming 0-based arrays An array of integers for the To values of the connections, assuming 0-based arrays A user Name as a string A Target Company as a string Output Your function should print how far is the Target Company for the given user name, and how many users exist at that level. Note: The program will be automatically tested by calling your HowConnected(int N, int C, string names[], string companies[],int from[], int to[], string name, string targetcompany) function. You are not allowed to change the signature of this function but you can expand your file and functions/classes as needed. Example 1: Input: N= 8 C= 10 From and To Arrays 0 1 0 2 0 7 1 4 2 3 2 5 3 6 4 7 5 6 6 7 Names: Omar Tuqa Aesha Ahmad Ali Salem Sara Firas Companies: A C C A B B B C Name: Omar Target Company: B answer: 2 3 Example 2: For the same input above but with Name: Omar Target Company: C answer: 1 3
main.cpp : #include
Enter
Mohammad
Q1.cpp : #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started