CST 370 Week 3
This week we got into some VERY important knowledge. Graphs. Both directional and unidirectional, as well as learning how to traverse these graphs. We learned the basic brute force string matching and exhaustive search way to solve problems...but then we learned about Depth First Search and Breadth First Search. Both of which are unique in their own way.
DFS uses stack and goes alphabetically until a vertex is already marked, then pops the stack and tries again with the vertices it hasn't been to yet. This is good for things that have 1 solution like getting out of a maze or sorting.
BFS uses a queue and is when you explore all the neighbors at a current vertex before going to the next. Best to find the shortest path in relation to cost, like the traveling salesman.
Comments
Post a Comment