Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a new version of your C++ program that creates instead a 2D array of 5x5 values of type boolean. Suppose indices represent people and

  1. Make a new version of your C++ program that creates instead a 2D array of 5x5 values of type boolean.  

  1. Suppose indices represent people and that the value at row i, column j of a 2D array is true just in case i and j are friends and false otherwise. Use initializer list to instantiates and initialize your array to represent the following configuration: 
     

  1. Write some code to count how many pairs of friends are represented in the array. Note that each friendship pair appears twice in the array, so in the example above there are 6 pairs of friends). 

  1. Write a method to check whether two people have a common friend. For example, in the example above, 0 and 4 are both friends with 3 (so they have a common friend), whereas 1 and 2 have no common friends. The method should have three parameters: a 2D array of Boolean representing the friendship relationships and two integers i, j. The method should return true if there is an integer k such that i is a friend of k and k is a friend of j and return false otherwise. Make this method static and test it from the main() method. 

#10 1 2 3 4 (* means "friends") 2 1 3 I 4

Step by Step Solution

3.52 Rating (149 Votes )

There are 3 Steps involved in it

Step: 1

include using namespace std function to add a friendship void addEdgei... 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

Research Methods Statistics and Applications

Authors: Kathrynn A. Adams, Eva Marie K. Lawrence

1st edition

1452220182, 978-1452220185

More Books

Students also viewed these Algorithms questions