12 views

Uploaded by Thu Vu

- lec05_uninformed_search.pptx
- daaa project
- DSA_MK_Lect4.pdf
- 5
- Search
- Integral graphs
- Greedy
- Asa 2011 Graphs
- Ensuring Ad Hoc Connectivity in Distributed Search
- (Book) Bertsimas, D. & Tsitsiklis, J. N. 19yy Introduction to Linear Optimization - Athena Scientific
- KD_Sudoku_TF_4up.pdf
- mod02
- Video Lecture Series - Engineering Courses
- MIT Dynamic Programming Lecture Slides
- Cannon2010-Distributed Scheduling Using Constraint Optimization and Multiagent Path Planning (1)
- NLN-LIVE-ICMC_SMC-2014_Proceedings.pdf
- hi
- Exercises
- Exercises
- Gmmubm Vqubm Comparison

You are on page 1of 4

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). Answer: a1. All noncyclic paths from A to D: ABEGFCD ABEGFCHD ABEGFHD ABEGFHCD ACD ACFHD ACHD a2. All noncyclic paths from B to H: BEGFCDH

A B C D

E G

Figure 1

Faculty of Computer Science and Engineering Department of Computer Science BEGFCH BEGFH a3. All noncyclic paths from E to C: EGFC EGFHC b. Give the adjacency matrix representation of the graph. A B C D E F G A 0 1 1 0 0 0 0 B 0 0 0 0 1 0 0 C 0 0 0 1 0 1 0 D 0 0 0 0 0 0 0 E 0 0 0 0 0 0 1 F 0 0 1 0 0 0 0 G 0 0 0 0 0 1 0 H 0 0 1 1 0 0 0 c. Give the adjacency list representation of the graph. ABC BE C D F H D H E G F C H G F H C D d. Give the depth-first traversal of the graph (supposed we start from A). Using alphabetic order: A C H F D B E G e. Give the breadth-first traversal of the graph (supposed we start from A). Using alphabetic order: A B C E D F H G Question 2. Given the graph in Figure 2, complete the following tasks:

H 0 0 1 1 0 1 0 0

Figure 2

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. Answer: a. Give the adjacency matrix representation of the graph. A B C D E F G H A 0 4 3 0 0 0 1 0 B 4 0 0 0 3 0 0 0 C 3 0 0 8 0 5 0 0 D 0 0 8 0 0 0 0 5 E 0 3 0 0 0 0 6 0 F 0 0 5 0 0 0 2 7 G 1 0 0 0 6 2 0 0 H 0 0 0 5 0 7 0 0 b. Give the adjacency list representation of the graph. A (B, 4) (C, 3)(G, 1) B (A, 4)(E, 3) C(A, 3) (D, 8)(F, 5) D(C, 8)(H, 5) E (B, 3)(G, 6) F (C, 5) (G, 2)(H, 7) G (A, 1)(E, 6)(F, 2) H(D, 5) (F, 7) c. Find the shortest path between node E and all other nodes in the above graph.

Faculty of Computer Science and Engineering Department of Computer Science Shortest Path from E to B: E B (3) Shortest Path from E to C: E B A C or E G A C (10) Shortest Path from E to D: E B A C D or E G A C D (18) Shortest Path from E to F: E G F (8) Shortest Path from E to G: E G (6) Shortest Path from E to H: E G F H (15)

A B C D

Question 3. Given the graph in Figure 3, generate the corresponding topology order using depth-first search and breadth-first search.

E G

Answer:A:marked. Using depth-first search: (Slides 40-44) Step 1 2 3 4 5 6 7 8 Stack H F F F G G G G G E E E E E E B B B B B B B A A A A A A A A Add First List H F G Result List: A C D B E G F H 9 10 11

Figure 3

12

13

14

E B A E

B A B

C A

D C A D

C A C

A A

Using Breadth-first search: (Slides 45-47) Step A B C D E F G H Add Last List 0 0 1 1 1 1 2 3 4 1 0 0 0 1 1 2 2 2 A 2 0 0 0 1 0 2 2 2 B 3 0 0 0 0 0 1 2 2 C 4 0 0 0 0 0 1 1 2 E 5 0 0 0 0 0 1 0 1 D 6 0 0 0 0 0 0 0 1 G 7 0 0 0 0 0 0 0 0 F 8 0 0 0 0 0 0 0 0 H Result List: A B C E D G F H --End--

Queue A BC CE ED D G F H

- lec05_uninformed_search.pptxUploaded bypaksmiler
- daaa projectUploaded byManish Gujjar
- DSA_MK_Lect4.pdfUploaded byAnkit Priyarup
- 5Uploaded byMastaneh Youshi
- SearchUploaded byMahabub Alam
- Integral graphsUploaded bydragance106
- GreedyUploaded byRuchi Joshi
- Asa 2011 GraphsUploaded byjhdmss
- Ensuring Ad Hoc Connectivity in Distributed SearchUploaded byMaximiano Martins
- (Book) Bertsimas, D. & Tsitsiklis, J. N. 19yy Introduction to Linear Optimization - Athena ScientificUploaded byMeysam Shahrbaf
- KD_Sudoku_TF_4up.pdfUploaded byingcarlosing
- mod02Uploaded byWolf's Rain
- Video Lecture Series - Engineering CoursesUploaded byIrus Rajan
- MIT Dynamic Programming Lecture SlidesUploaded byscatterwalker
- Cannon2010-Distributed Scheduling Using Constraint Optimization and Multiagent Path Planning (1)Uploaded bychristophertcannon
- NLN-LIVE-ICMC_SMC-2014_Proceedings.pdfUploaded byThan Van Nispen
- hiUploaded bysampritc

- 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
- Tut5Uploaded 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
- 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

- Local Leaders, Local CultureUploaded byCourtneyMcCleister
- Foxpro SampleUploaded byMayur
- excrptsUploaded byGanesh Kumar
- final draft of researchUploaded byapi-384230096
- Prof Paul_ SSI in Surgery.pdfUploaded bywidia yuniarti ningsih
- Gandhara-n-Sculptures.pdfUploaded byIzhaŕ Ķẳsì
- Jelly Roll MortonUploaded byMarco D'Agostino
- spanish 1 curriculum mapUploaded byapi-283923812
- 1104201616 a AUploaded byAyush
- Ralph Waldo EmersonUploaded byCape Town
- SudokuUploaded byarchtf
- Xi Lecture SheetUploaded byaman
- Heroes and Heroines of ChivalryUploaded byKelli
- Community-Acquired Pneumonia and Tuberculosis; Differ Dx and the Role of Quinolones - Intern J Infect Dis 2014Uploaded byPanayiotis Stavroulakis
- MCAS Office 2007 Exam Prep-Exams for Microsoft Office 2010Uploaded bymaitcpt
- Hedgings AcademicUploaded byJorge Carvalho
- Normality, Z Score and BasicsUploaded byguru9anand
- Structure of NsUploaded bycuyyah
- The International Handbook on Aging.pdfUploaded byYvonne Yap Ying Ying
- Logic - Atty. Obieta - Midterms 2014Uploaded byj531823
- Hindu GodsUploaded bymhimali
- 13. Nietzsche Selections.pdfUploaded byflicky_g
- Operations Management, 10th Edition chapter 4Uploaded byArdale Palillo
- ADNOC-COPV6-01(Ver-1)Uploaded byNaveenKrishnaS
- Bus 601 Case3_07vrUploaded bysaaima123
- D 2950 - 91 R97 _RDI5NTA_.pdfUploaded byAarah Khalid
- Reflection Social TransformationUploaded byeliescribd
- Deconstructing the Enemy Representation in HollywoodUploaded byIman Khan
- 2007-10-CoSALEN-EPUploaded bybrunompaz
- Good Shepherd ANCC Weekly BulletinUploaded byRichard Ciullo