1 / 27

Graphs

Explore different types of records and their usage in graphs. Learn about searching algorithms and the importance of order in data structures.

emanuelp
Télécharger la présentation

Graphs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphs

  2. Types of Records One link – For stack and queue. Two links – For double ended queue. Many links:

  3. Order is important

  4. Searching in a Graph A 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

  5. VISIT(v) D INSERT(v) While D≠Ø do x REMOVE(D) visit and mark x for all unmarked w adjacent to x do D INSERT(w) end end

  6. Depth-First Search D is LIFO: D PUSH(v) While D≠Ø do x POP(D) visit and mark x for all unmarked w adjacent to x do D PUSH(w) end end A B C E F D

  7. Breadth-First Search D is FIFO: D ENQUEUE(v) While D≠Ø do x DEQUEUE(D) visit and mark x for all unmarked w adjacent to x do D ENQUEUE(w) end end A B C E F D

  8. אינפי 1 לינארית 1 מבוא לחישוב מבני נתונים לינארית 2 אינפי 2 מיון טופולוגי • כידוע יש באוניברסיטה לכל קורס דרישות קדם • נניח שאני מעוניין לקחת קורס אחד לסמסטר • תן אלגוריתם שיגיד איזה קורס לקחת באיזה סמסטר. אינפי 1 לינארית 1 אינפי 2 לינארית 2 מבני נתונים מבוא לחישוב

  9. Algorithm • Topological-Sort() • { • Call DFS to compute finish time for each vertex • Insert vertex finished into the beginning of linked list • Return the linked list of vertices • } • הזמן זהה לחיפוש לעומק והוא O(V+E).

  10. Socks Undershorts Watch Shoes Pants Shirt Belt Tie Jacket Example

  11. Socks Undershorts Watch Shoes Pants Shirt Belt Tie Socks Undershorts Shoes Pants watch Shirt Tie Jacket Belt Jacket Example

More Related