Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

the question is in the picture Lab9: Mini-map What you need to do You can be as

ID: 3552978 • Letter: T

Question

the question is in the picture

Lab9: Mini-map What you need to do You can be as creative as possible for this lab, to solve a problem. Here's a tiny map consists of several nodes, your task is to figure out a structure to represent this map, gather information with scanf (which means you have to build the map node by node), and print out the following: All the nodes in the map (order doesn't matter), you have to really walk through the map to find out instead of hard-code all the nodes in a string Based on an input, find all the adjacent nodes (1 as the distance) Based on two inputs (a node and the distance), find all the nodes within that distance NOTE that You should not walk through one node twice (maybe another variable to keep track of nodes visited? Or something else, use whatever method you like) When the input is invalid (nonexistent node, negative distance, but is 0 a valid input?), handle properly What to Hand In First, let us go back up to our cs449 directory: cd Now, let us first make the archive. Type your username for the USERNAME part of the filename: tar cvf USERNAME Iab9.tar lab9

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

int a[8][8],n;

int i,j;

char p,q;

for(int i=0;i<8;i++)

{

for(int j=0;j<8;j++)

{

a[i][j]=0;

}

}

//using adjacency matrix structure to represent the graph

for(i=0;i<8;i++)

{

p='A' + i;

for(j=0;j<8;j++)

{

q='A' + j;

if(i!=j)

{

printf("Do %c and %c share an edge.. press 1 for yes and 0 for no : ",p,q);

scanf("%d",&a[i][j]);

}

else

{

a[i][j]=1;

}

}

}

printf("Nodes of the maps are ");

for(i=0;i<8;i++)

{

printf("%c ",'A'+i);

}

for(int i=0;i<8;i++)

{

p='A' + i;

printf("adjacent nodes of %c are : ",p);

for(j=0;j<8;j++)

{

q='A' + j;

if(i!=j)

{

printf("%c ",q);

}

}

}

scanf("%d",&n);

return 0;

}