יסודות מבני נתונים תרגול 13: עץ פורש מינימלי - Minimum Spanning Tree (MST)

Slides:



Advertisements
מצגות קשורות
ילדי גן "יסמין" וגן פרפר נחמד" נוטעים יחד עם חיילי סמ"ג חוף
Advertisements

SQL: שינוי מסד הנתונים- פעולותDDL , DML
קורס ניהול ידע מפגש 3 - פורטלים 2know.kmrom.com.
תגובות חמצון -חיזור ודוגמאות מחיי היום יום
Trends in Periodic Table Properties
על הסתיו ועוד, בגן ה"תמרים" בעכו שם הגננות: מירב קדוש אלה נאמן
Ford Fulkerson.
לולאות Department of Computer Science-BGU 19 יולי 19.
The Partnership tree in ECP- Austin עץ השותפות באוסטין
טקס פתיחת "גינת השותפות" בעכו
כיצד להשתמש באתר הספרייה הדיגיטלית הישראלית
Isotopes and Atomic Mass
Encounters in Jerusalem
OOO Execution of Memory Operations
עולם הסביבונים.
Marina Kogan Sadetsky –
אלקטרושליליות ופולריות הקשר
רקורסיה ופתרונות רקורסיביים
מודל דחיית זוגות אלקטרונים של קליפת הערכיות
Present Perfect Simple
תרכובות עם יונים פוליאטומים בחיי היום יום
רקורסיה ופתרונות רקורסיביים
זאב וקסמן פישר מנהל ישראגריד 15/11/11

חוק שימור החומר The Law of Conservation of Mass indicates that in an
The Dolphin Class International Forest of Support
DIPLOMACY AND INTERNATIONAL COMMUNICATION
חג פורים שמח ומבדח מגן פרפר....תפן שם הגננת: מאיה פלס
מבני נתונים תרגול 3 ליאור שפירא.
OOO Execution of Memory Operations
Mantled Howler Monkey - Alouatta palliata
Akiba Academy of Dallas Presents
תכנון סכמות רלציוניות איזה תכנון טוב יותר? Customer Ordered CustOrders
Short Documentation from “Yom Hatzmaut” activities in ECP – Austin TX תיעוד קצר מהפעילויות בגיל הרך בבית הספר היהודי באוסטין טקסס לקראת יום העצמאות.
ט"ו בשבט בגן " תומר" Tu Bishvat in “Tomer” kindergarten
S. Even, "Graph Algorithms", Computer Science Press, 1979
האם אתם יודעים כיצד כותבים מגילה?
את כל מרכולתנו הבאנו לגן ותראו מה עשינו!!!!
חג הפסח בגן בקיבוץ ראש הנקרה שם הגננת: חנה רום
MITUG.COM האתר של פטריק –
מוטיבציה והשוואה בין מבני נתונים שלמדנו
Direction of induced current
חנוכה בגן "יסמין"-עכו Hanukkah in "Yasmin" kindergarten Akko
שם הגננת: עדנה סרי The teacher: Edna Seri
הכנה למבחן.
Class VI: Adjectives Dr. Esa Autero
מבוא למערכות מידע גיאוגרפיות
¡ IT SEEMS IMPOSSIBLE ! נראה בלתי אפשרי! הגנרל אייזנהאואר צדק בפוקדו
Computer Architecture and System Programming Laboratory
בתרכובות יוניות יש קשרים יונים
תיעוד מפעילויות ראש השנה בגן "פרפר נחמד" –עכו-תש"ע
Elements and Symbols יסודות וסמלים מהם יסודות? gold carbon aluminum
Marina Kogan Sadetsky –
Emech at 1 + W = Emech at 2 mgh1 = mgh2
אוניברסיטת בר-אילן לשכת סגן הרקטור המרכז לקידום הוראה מציגים:
What is Chemistry? מהי כימיה? Chemistry is the study of matter and its
צמצום בעזרת מפת קרנו.
מודלים של שיווי משקל לצורכי תכנון תחבורה
קומבינטוריקה למדעי-המחשב EULER GRAPHS גרפים אויילרים
הכנת שמן זית וארכיאולוגיה בגן "ארגמן" עכו Preparing olive oil and Archeology at “Argaman” kindergarten in Akko שם הגננת: נטלי גוריבודסקי שם הסייעת :
עקרונות תכנות מונחה עצמים תרגול 8: OOP in C++
גן "יסמין "עכו שם הגננת: מרגלית פוגל שם הסייעת: זיוה אוזן
“Augustus and his smile” “"חיוכו של נסיך
Tutorial #10 MIPS commands
שם הגננת:אתי ברכפלד קיבוץ סער
יינון המים In the ionization of water,
רקורסיה ופתרונות רקורסיביים
בגן" הדס" בעכו משלבת פרלה שטרית הגננת ,בין חנוכה לבין השמירה על איכות הסביבה. פרלה בקשה מהילדים להכין בביתם חנוכייה מחומרים ממוחזרים או מחומרים שאינם.
תמליל מצגת:

יסודות מבני נתונים תרגול 13: עץ פורש מינימלי - Minimum Spanning Tree (MST)

Minimum Spanning Tree (MST) Kruskal’s algorithm Select the shortest edge in a network Select the next shortest edge which does not create a cycle Repeat step 2 until all vertices have been connected Prim’s algorithm Select any vertex Select the shortest edge connected to that vertex Select the shortest edge connected to any vertex already connected Repeat step 3 until all vertices have been connected

Example Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E List the edges in order of size: ED 2 AB 3 AE 4 CD 4 BC 5 EF 5 CF 6 AF 7 BF 8 CF 8 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm Select the shortest edge in the network B C 3 6 8 F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 (or AE 4) A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the next shortest edge which does not create a cycle ED 2 AB 3 CD 4 AE 4 BC 5 – forms a cycle EF 5 A F B C D E 2 7 4 5 8 6 3

Kruskal’s Algorithm B C 3 6 8 A D F 7 5 4 2 E All vertices have been connected. The solution is ED 2 AB 3 CD 4 AE 4 EF 5 Total weight of tree: 18 A F B C D E 2 7 4 5 8 6 3

Example Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select any vertex A Select the shortest edge connected to that vertex AB 3 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. AE 4 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. ED 2 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. DC 4 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E Select the shortest edge connected to any vertex already connected. EF 5 A F B C D E 2 7 4 5 8 6 3

Prim’s Algorithm B C 3 6 8 A D F 7 5 4 2 E All vertices have been connected. The solution is AB 3 AE 4 ED 2 DC 4 EF 5 Total weight of tree: 18 A F B C D E 2 7 4 5 8 6 3

Some points to note Both algorithms will always give solutions with the same length. They will usually select edges in a different order. Occasionally they will use different edges – this may happen when you have to choose between edges with the same length. In this case there is more than one minimum connector for the network.

Kruskal Prim מתחילים בכך שכל קדקוד גרף הוא עץ כל פעם נוסיף קשת בעלת משקל מינימלי המחברת בין שני עצים שונים מסיימים כאשר הוספנו |V|-1 צלעות זמן ריצה O(E logV) Prim מתחילים מקדקוד רנדומלי R שהוא יהיה שורש של MST כל פעם מוסיפים קדקוד חדש v לעץ פורש כך שהקשת המחברת את v עם MST היא בעלת משקל מינימלי מסיימים כאשר הוספנו |V|-1 צלעות זמן ריצה O(E logV) שאלה: האם נכון להגיד שאם בגרף יש שתי צלעות לפחות עם משקל זהה שמשתתפות באותו מעגל, אז יש לגרף הזה יותר מעץ פורש מינימלי אחד? שאלה: האם נכון להגיד שאם בגרף יש שתי צלעות לפחות עם משקל זהה, אז יש לגרף הזה יותר מעץ פורש מינימלי אחד? תשובה: לא. לדוגמא נקח גרף שהוא מעגל עם שלוש צלעות עם משקלות 1,1,ו 2. ברור שלגרף הזה יש MST יחיד, שבמקרה הזה גם מכיל את שתי הצלעות עם משקל זהה. תשובה: לא. אם גרף הוא עץ כאשר לכל הצלעות אותו משקל (דוגמא קיצונית), הרי ברור שיש לגרף הזה עץ פורש יחיד

שאלה 1