The focus of the reading is graphs, specifically adjacency list and adjacency matrix representation, and depth-first search
The readings for Thursday, February 14 are:
Data Structures and Other Objects Using C++:
If you do not have the primary textbook, you can use the following free alternative texts instead:
Once you have completed the readings, answer the following questions:
Briefly explain what it means for a graph to be:
A. Connected?
B. Acyclic?
C. Directed?
D. Simple?
E. Weighted?
Given the following non-recursive implementation of depth-first search:
struct Graph { map<string, set<string>> adj; // Adjacency List/Set }; void traversal(Graph &g, const string &s) { stack<string> q; set<string> v; // TODO while (!q.empty()) { // TODO } }
A. Complete the implementation of depth-first search by filling in the
TODO
sections with the appropriate C++ code. Remember to:
Print out each node you visit.
Visit each node exactly once.
B. What is the purpose of stack<string> q
?
C. What is the purpose of set<string> v
?
To submit your reading assignment, you must upload a text/PDF file onto Canvas prior to class