Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

main.cpp : #include using namespace std; #include "Q1.cpp" #include int main(){ int N=8, C=10; string names[8]={"Omar","Tuqa","Aesha","Ahmad","Ali","Salem","Sara","Firas"}; string companies[8]={"A","C","C","A","B","B","B","C"}; int from[10]={0,0,0,1,2,2,3,4,5,6}; int to[10]= {1,2,7,4,3,5,6,7,6,7}; HowConnected(N,C,names,companies,from,to,"Omar","B"); //answer should be 2 3 HowConnected(N,C,names,companies,from,to,"Omar","C"); //answer should be 1 3 return 0; }

Enter

Mohammad

Q1.cpp : #include using namespace std; #include void HowConnected(int n, int c, string names[], string companies[],int from[], int to[], string name, string target_company){ cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions

Question

3. Is it a topic that your audience will find worthwhile?

Answered: 1 week ago

Question

2. Does the topic meet the criteria specified in the assignment?

Answered: 1 week ago