Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a two dimensional array, suppose indices represent people and that the value at rowi,column of the array is in case i and are friends

image text in transcribed

In a two dimensional array, suppose indices represent people and that the value at rowi,column of the array is in case i and are friends and otherwise. Initialize your array to represent the following configuration: # 1 0 1 2 3 4 -- 0 1 1 I * 21 31 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 6 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 Lj. The method should return true if there is a k such that i 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

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

More Books

Students also viewed these Databases questions

Question

Discuss consumer-driven health plans.

Answered: 1 week ago

Question

=+what information would you need about the compact disc industry?

Answered: 1 week ago