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

Can someone give me guidance as to what I am doing wrong? I\'m trying to search

ID: 3666097 • Letter: C

Question

Can someone give me guidance as to what I am doing wrong? I'm trying to search a 2d array/map with BFS basically

struct Location {// simple location type
int x;
int y;
};
struct Node {
struct Location loc;
//int dist; //distance from root in tree
struct Node *front;
struct Node *rear;
};
struct Map { //variable size encompassing array, and dimension variables
char arr[100][100];
int xLength;
int yLength;
struct Node currLoc;
struct Node pq;
};
void pop(struct Map *map){
if (map->pq.front != NULL){
if (map->pq.front == map->pq.rear){
map->pq.rear = NULL;
}else{
map->pq = *map->pq.front;
}
}
}

void push(struct Map *map, struct Location location){
struct Node temp;
temp.loc = location;
temp.front = map->pq.rear;
temp.rear = NULL;
if(map->pq.rear == NULL) {
map->pq.front = &temp; // First NODE
map->pq.rear = map->pq.front;
}else{// if there is stuff in the queue
map->pq.rear->rear = &temp;
map->pq.rear->front = map->pq.rear;
map->pq.rear = map->pq.rear->rear;
// Insert End
}
}

Explanation / Answer

int main()   // start main
{
struct Location *l1;
struct Node *n1;
struct map *m1;
n1->push(m1, l1);


return 0; // exit
} // end of main()


// the following code can be used :

void beadthFirstSearch(int node) {
   for (i=1; i<=total; i++)
       if array[node][i] && !traversed[i])
           arrayQ[++rear] = i;
       if (front <= rear)   {
           traversed[arrayQ[front]]=1;
           breadthFirstSearch

{arrayQ[front++]);
       } // end if
} // end function bfs
  
int main()   // start main
{
struct Location *l1;
struct Node *n1;
struct map *m1;
n1->push(m1, l1);

int vertex, vertices;
cout << "Input the count of nodes: ";
cin >> vertices;
for(i=1; i<=vertices; i++) {
   arrayQ[i]=0;
   traversed[i]=0;
}
cout << "Input the data for the graph - in rows by columns";
for(i=1; i<=vertices; i++)
   for(j=1; j<= vertices; j++)
       cin >> array[i][j];
cout << "Input the opening node:";
   cin >> vertex;
breadthFirstSearch(vertex);
cout << "The traversable nodes are listed below:";
for (i=1; i<= vertices; i++)
   if (traversed[i])
       cout << "   " << i << "       ";
   else
       cout << " Unreachble node";
}