Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help in C + + , problem and instructions are in the photo, here are a few requirements :These are the member variables of
Please help in C problem and instructions are in the photo, here are a few requirements :These are the member variables of the Graph class that you will need to use in your implementation:
std::list graph
This is an array of pointers, where each pointer points to an STL list of type int.
Each STL list stores the adjacent vertices to the vertex that corresponds to the index of the array.
For example, at index of the array, the list to which the pointer at index is pointing stores all the adjacent vertices to vertex
int numOfVertices
The variable numOfVertices stores the number of vertices in the graph.
The capacity of the graph is irrelevant in your implementation, because the graph has already been built.
I recommend you draw the array with all pointers and all the lists showing the adjacent vertices.
Parameter: An empty array that is already set to have capacity equal to the number of vertices in the graph. The parameter array must be named bfsData.
The function must behave as shown on the lesson slides. The final BFS must be stored in the parameter array bfsData, which will be printed outside the function; this means that there is NO printing done in this function.
Note that if implemented properly, this function will be no longer than complete statements this does not include empty lines or brackets If it is longer than that, make sure you revisit your implementation to clean it up
Requirements:
Parameter identifier: bfsData
The unvisited sequence must be represented by a dynamic array of type Boolean.
To create the queue use the custom class Queue this is NOT the STL queue class It includes all the necessary functions default constructor, push, pop, empty, front but it is not a template class.
The implementation must strictly follow the traversal shown on the slide other implementations will not be accepted
The implementation must be efficient, and in particular, it must control the loops to avoid looping unnecessarily as explained on the slides
You may not create containers other than the ones mentioned above.
This means that your implementation will work with containers only: the dynamic array unvisited sequence the queue, and the parameter array to store the BFS
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