Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many...
-
Upload
sibyl-powell -
Category
Documents
-
view
216 -
download
0
Transcript of Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many...
![Page 1: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/1.jpg)
Graphs
![Page 2: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/2.jpg)
Types of RecordsOne link – For stack and queue.
Two links – For double ended queue.
Many links:
![Page 3: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/3.jpg)
![Page 4: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/4.jpg)
Order is important
![Page 5: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/5.jpg)
![Page 6: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/6.jpg)
![Page 7: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/7.jpg)
![Page 8: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/8.jpg)
![Page 9: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/9.jpg)
![Page 10: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/10.jpg)
![Page 11: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/11.jpg)
![Page 12: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/12.jpg)
![Page 13: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/13.jpg)
![Page 14: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/14.jpg)
![Page 15: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/15.jpg)
Searching in a GraphA Generic algorithm:Let G=(V,E) be the graph.Let D be a data structure (we’ll later
see which one).
For unmarked vertex v:VISIT(v)
end
![Page 16: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/16.jpg)
VISIT(v)D INSERT(v)While D≠Ø do
x REMOVE(D)visit and mark xfor all unmarked w adjacent to x do
D INSERT(w)end
end
![Page 17: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/17.jpg)
Depth-First SearchD is LIFO:D PUSH(v)While D≠Ø do
x POP(D)visit and mark xfor all unmarked w adjacent to x do
D PUSH(w)end
end
A
B C
D E F
![Page 18: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/18.jpg)
Breadth-First SearchD is FIFO:D ENQUEUE(v)While D≠Ø do
x DEQUEUE(D)visit and mark xfor all unmarked w adjacent to x do
D ENQUEUE(w)end
end
A
B C
D E F
![Page 19: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/19.jpg)
![Page 20: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/20.jpg)
![Page 21: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/21.jpg)
![Page 22: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/22.jpg)
![Page 23: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/23.jpg)
![Page 24: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/24.jpg)
מיון טופולוגיכידוע יש באוניברסיטה לכל •
קדםקורס דרישות
נניח שאני מעוניין לקחת • לסמסטר אחדקורס
שיגיד איזה אלגוריתםתן •קורס לקחת באיזה סמסטר.
אינפי 1
אינפי 2
לינארית 2
לינארית 1
מבני נתונים
מבוא לחישוב
אינפי 1
לינארית 1
לינארית 2
מבוא לחישוב
מבני נתונים
אינפי 2
![Page 25: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/25.jpg)
Topological-Sort )( {
Call DFS to compute finish time for each vertexInsert vertex finished into the beginning of linked listReturn the linked list of vertices
{
.)O)V+Eהזמן זהה לחיפוש לעומק והוא
Algorithm
![Page 26: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/26.jpg)
Example
Undershorts
Watch
Socks
Jacket
Tie
Shirt
Belt
ShoesPants
![Page 27: Graphs. Types of Records One link For stack and queue. Two links For double ended queue. Many links:](https://reader035.fdocuments.us/reader035/viewer/2022062413/5a4d1b7f7f8b9ab0599ba58d/html5/thumbnails/27.jpg)
ExampleUndershorts
WatchSocks
Jacket
Tie
ShirtBelt
ShoesPants
Socks JacketUndershorts Pants Shoes watch Shirt Belt Tie