11 views

Uploaded by Thu Vu

You are on page 1of 2

Tutorial 5 Questions Graph

Required Questions Question 1. Given the graph in Figure 1, complete the following tasks: a. Find a1. All noncyclic paths from A to D a2. All noncyclic paths from B to H a3. All noncyclic paths from E to C b. Give the adjacency matrix representation of the graph. c. Give the adjacency list representation of the graph. d. Give the depth-first traversal of the graph (supposed we start from A). e. Give the breadth-first traversal of the graph (supposed we start from A).

A B C D

E G

Figure 1

Question 2. Given the graph in Figure 2, complete the following tasks: a. Give the adjacency matrix representation of the graph. b. Give the adjacency list representation of the graph. c. Find the shortest path between node E and all other nodes in the above graph. Question 3. Given the graph in Figure 3, generate the corresponding topology order using depth-first search and breadth-first search.

B A C D Figure 2

E G

Figure 3

Faculty of Computer Science and Engineering Department of Computer Science Advanced Question Question 4. A mouse wants to go through a maze as described in Figure 4. When choosing between multiples nodes, the mouse always take the node appearing first in alphabetical order. When meets the dead end, the mouse turns back and choose another possible path. For example, if starting from A and wanting to go to O, the path that the mouse follow will be: A >> B >> C >> D >> (back to) C >> G >> F >> H >> I >> (back to) H >> J >> K >> (back to) J >> L >> M >> (back to) L >> N >> (back to) L >> O

Figure 4

Write an algorithm that prints out all of the nodes that the mouse will visit in proper order.

Algorithm printOut (val M <Maze>, Start <Node>, Goal <Node>) Pre Start and Goal are two nodes in Maze Return None

- ExercisesUploaded byThu Vu
- ExercisesUploaded byThu Vu
- Gmmubm Vqubm ComparisonUploaded byThu Vu
- Assignment Web ProgrammingUploaded byThu Vu
- thicuoikyUploaded byThu Vu
- nhan dang nguoi noiUploaded byThu Vu
- ExercisesUploaded byThu Vu
- vq-ubmUploaded byThu Vu
- dsachdot1Uploaded byThu Vu
- Report 1Uploaded byThu Vu
- ClippingUploaded byThu Vu
- Tut 2Uploaded byThu Vu
- Tut 7_SolUploaded byThu Vu
- Kinh Nghiem Sat Hach CNTTUploaded byBố Đéo
- ExercisesUploaded byThu Vu
- Tut2 SolutionUploaded byThu Vu
- Tut2_200213Uploaded byThu Vu
- Tut2_200213Uploaded byThu Vu
- Exercise1_w2_vn_v1.1Uploaded byThu Vu
- Tut 4Uploaded byĐừngh
- Tut5_SolUploaded byThu Vu
- Final 2010Uploaded byThu Vu
- Final 2010Uploaded byThu Vu
- Tut+6Uploaded byThu Vu
- Tut+6 Sol ReleaseUploaded byThu Vu
- Final2011 SolUploaded byThu Vu
- LayoutUploaded byThu Vu
- Tut1 SolutionUploaded bybuiductaianh
- dsachdot1Uploaded byThu Vu