{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

q2keysp01 - COP3530.01 Spring 2001 S Lang 1 Partial...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
COP3530.01, Spring 2001 April 20, 2001 S. Lang Partial Solution Key to Quiz #2 1. Suppose an undirected graph G = ( V , E ) is represented in its adjacency lists structure, see the following figure for the graph and its representation. (b) (8 pts.) Write in C++ or Java ( circle which one!) to implement the breadth-first-search (BFS) method, assuming a FIFO queue class Queue (of integers) is available which contains the following methods: Queue(): a constructor for an empty Queue object. boolean isEmpty(): a method that tells if a Queue object is empty (true) or not (false). void add(int x): add integer x to the end of the Queue object. int remove(): remove and return the first integer at the front of the Queue object (throw an exception if the Queue is empty). Your void BFS(int x) method should print out the node numbers as they are being visited, starting at node x. You may assume int n gives the number of nodes, and array adjLists[1. .n] gives the adjacency lists structure. Specify any additional data structures you may need. (Consult the text and the notes for the BFS function.)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

q2keysp01 - COP3530.01 Spring 2001 S Lang 1 Partial...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online