CS367 Homework 7
| ||
AnnouncementsCheck here periodically.
| ||
QuestionsWhat do I need to answer? Question 1:Consider the following graph: ![]() Recall that the 367 convention for searching successors is to do so alphabetically (or numerically if the nodes have numbers). Part A: Show the order that nodes are visited for depth-first search on the graph above starting at node A and using the 367 convention for searching successors. Part B: Show the order that nodes are visited for breadth-first search on the graph above starting at node A and using the 367 convention for searching successors. Question 2:Below is an incomplete definition of the Graphnode class. class Graphnode<T> { private boolean visitMark; private List<Graphnode<T>> successors; public boolean getVisitMark () { return visitMark; } public void setVisitMark (boolean mark) { visitMark = mark; } public List<Graphnode<T>> getSuccessors() { return successors; } } Write the existsPath method whose header is provided below. This method returns true iff there exists a path from Graphnode start to Graphnode dest. Your implementation must be based on the depth-first search algorithm (i.e., modify DFS to implement existsPath) and it must exit early if possible. You may assume that all the nodes in the graph have been marked unvisited prior to the existsPath method being called. public boolean existsPath( Graphnode<T> start, Graphnode<T> dest ) | ||
Handing inPlease include your name at the top your file. Put your answers to the questions into one file named Homework7 with the appropriate file extension, e.g., Homework7.pdf (see File Format for acceptable file formats). Electronically submit your work to the Homework 7 Dropbox on Learn@UW. | ||
Last Updated: 7/31/2014 © 2014 Beck Hasti |