Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Challenge Attachments Adjacency Matrix Programming challenge description: Write a program that builds an adjacency matrix representation of a simple undirected graph. Input: An undirected graph

image text in transcribed

image text in transcribed

image text in transcribed

Challenge Attachments Adjacency Matrix Programming challenge description: Write a program that builds an adjacency matrix representation of a simple undirected graph. Input: An undirected graph represented as an adjacency list. Each line of input contains one element of the list, which is a space-separated set of numbers. The first number is a vertex index, and all other are the vertices that the current vertex is adjacent to. Vertex indices are continuous integer numbers from 0 to (12 1), where n is a count of vertices in the graph. So for example: 01231 103 2 3 4 3@12 4 0 2 The first row means that vertex with index O is adjacent to (i.e., shares an edge with) the vertices 1, 2, 3, and 4. The second row means that vertex 1 is adjacent to vertices 0 and 3, and so on. See the attachments tab for an image representation of this graph. Output: An adjacency matrix of the given graph that is a square X matrix containing only zeros and ones. The element in the cross of the i row and the j column is equal to 1 if and only if there is an edge between vertices i and j in the graph. Each row of the output contains space-separated elements of the corresponding row of the adjacency matrix. For example: 01111 1 @@10 10 0 11 1110 10100 Test 1 Test Input 0 1 2 3 4 103 20 34 30 12 Expected Output 0 1 1 1 1 100 10 100 il 1 1100 1 0 1 0 0 Test 2 Test Input 012 102 201 Expected Output 011 101 110 Test 3 Test Input 0 1 2 3 10 23 2 0 1 3 4 3 0 1 2 5 2 5 6 5 3 4 6 7 6 4 57 7 4 5 6 Expected Output 01110000 1 0110000 1 1 0 1 1 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 1 0 1 00001110 Test 4 Test Input 0145 10 26 2 1 3 7 3 2 4 8 0 39 0 78 1 8 2 5 9 94 67 Test 4 Test Input 6 0 1 4 5 1 0 2 6 2 1 3 7 3 2 4 8 4 0 39 5 078 6 1 8 9 7 2 5 9 8 3 5 6 9 4 6 7 Expected Output 0 1 0 0 1 1 0 0 0 0 1010001000 0 1 0 1 0 0 0 1 0 0 0010100010 1 0 0 1 0 0 0 0 0 1 1000000110 010 0 0 0 0 0 1 1 0 0 1 0 0 1 0 0 0 1 0001 011000 0 0 0 0 1 0 1100 Convright 2012-2022 by HireVue All rights reserved. Unauthorized convina publication or disclosure prohibited

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago