a.Depth First Search
b.Breadth-First Search
Assume A is the root and the vertices are ordered as A,B,C,D,E
I have problems on both options after trying it.
For DFS, here's my workings:
1. A , Edge()
2. AB , Edge( AB )
3. ABD , Edge( AB,BD )
4. ABDE , Edge(AB,BD, DE)
5. ABDEF , Edge(AB, BD, DE, EF)
I stopped here because I'm not sure whether vertex G is included or not? since adjacent of D in ordered pair will go to vertex E instead of G
For BFS,here's my workings:
1. A, Edge()
2. AB , Edge(AB)
3. ABC, Edge(AB,AC)
4. ABCF, Edge(AB,AC,AF)
5. BCF, Edge(AB,AC,AF)
now,the adjacent of B will be D, so should I write BCFD or BCDF? since the question would request me to write in ordered pair.
Can someone guides me? I appreciate your time!
Thanks!

New Topic/Question
Reply


MultiQuote





|