Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

c++ In a two dimensional array, suppose indices represent people and that the value at row i, column of the array is 1 in case

c++ image text in transcribed
In a two dimensional array, suppose indices represent people and that the value at row i, column of the array is 1 in case and are friends and otherwise. Initialize your array to represent the following configuration # 10 1 2 3 4 0 Your array in your implementation should have 1 where you see a star and where there's nothing. a) Write a function that counts how many pairs of friends are represented in the array. Note that each friendship pair appears twice in the array (0 and 1 are friends but also 1 and 0 are friends). So in the example above there are actually only 5 pairs of friends. b) Write a function to check whether two people have a common friend. For example, in the example above, O and 4 are both friends with 3 (so they have a common friend), whereas 1 and 2 have no common friends. The function should have three parameters: a 2D array of integers (1s and Os) representing the friendship relationships and two integers J. The method should return true if there is a k such that is a friend of k and k is a friend of j and return false otherwise. Test the functions in a main program. The main program should print out how pairs of friendship exist using the function in a) and it should get input from user (two numbers) and check if those two numbers (individuals) have a common friend, 1 AB I 1% 3

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students explore these related Databases questions