Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question No. 1: Graphs Given an undirected Graph of N vertices, 1 to N and M edges in the form of a 2D array. The
Question No. 1: Graphs Given an undirected Graph of N vertices, 1 to N and M edges in the form of a 2D array. The array Arr [][], where every row consists of two numbers X and Y which denotes that there is an edge between X and Y. Input: N = 8, M = 7, Arr [] [] = {{1, 2}, {2,3}, {4,5}, {1,5}, {6, 1}, {7,4}, {3,8}} Your output will be: 0 1 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 Considering the above information, perform the following tasks: (a) Write a program to create an Adjacency Matrix of the given Graph. 1 (b) Write a program to create the Adjacency List of the above matrix
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