Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| courses:cs211:winter2018:journals:devlinn:chapter3 [2018/02/04 19:05] – devlinn | courses:cs211:winter2018:journals:devlinn:chapter3 [2018/02/04 19:05] (current) – [3.3 Implementing Graph Traversal Using Queues and Stacks] devlinn | ||
|---|---|---|---|
| Line 36: | Line 36: | ||
| ===== 3.3 Implementing Graph Traversal Using Queues and Stacks ===== | ===== 3.3 Implementing Graph Traversal Using Queues and Stacks ===== | ||
| - | The two basic ways to represent graphs are **adjacency matrices** and *adjacency lists**. When assessing the running time of algorithms which use either of these representations, | + | The two basic ways to represent graphs are **adjacency matrices** and **adjacency lists**. When assessing the running time of algorithms which use either of these representations, |
| When processing a set of elements, which often occurs in graph search algorithms, it is critical to determine how to ideally represent these elements. //Stacks// and //queues// are frequently used in this role, because it is frequently necessary to maintain a particular order for traversing the elements. Queue elements are extracted in //first-in, first-out// (FIFO) order, and stack elements are extracted in //last-in, first-out// (LIFO) order. The BFS algorithm uses a queue-like structure, as can be seen in the following sketch of the algorithm: | When processing a set of elements, which often occurs in graph search algorithms, it is critical to determine how to ideally represent these elements. //Stacks// and //queues// are frequently used in this role, because it is frequently necessary to maintain a particular order for traversing the elements. Queue elements are extracted in //first-in, first-out// (FIFO) order, and stack elements are extracted in //last-in, first-out// (LIFO) order. The BFS algorithm uses a queue-like structure, as can be seen in the following sketch of the algorithm: | ||
