מבני נתונים ואלגוריתמים - מחברת קורס/אלגוריתמים/סדרי גדילה: הבדלים בין גרסאות בדף
תוכן שנמחק תוכן שנוסף
ביטול גרסה 53328 של Thedsadude (שיחה) |
|||
שורה 84:
}}
הקבוצה <math dir = "ltr">\displaystyle O(g(n))</math> הנה קבוצת כל הפונקציות <math dir = "ltr">\displaystyle f(n)</math> כך ש<math dir = "ltr">\displaystyle f(n)</math>, עבור <math dir = "ltr">\displaystyle n</math> גדול מספיק, חסומה מלמעלה ע"י <math dir = "ltr">\displaystyle c \cdot▼
▲g(n)</math> עבור <math dir = "ltr">\displaystyle c > 0</math> כלשהו.
▲הקבוצה <math dir = "ltr">\displaystyle
{{הגדרה|תוכן =
<math dir = "ltr">\displaystyle
[[תמונה:theta intuition.png|מרכז|100%|אינטואיציה לתטא.]]▼
בהינתן פונקציה
כן, משום שעבור <math dir = "ltr">\displaystyle n \ge 1</math>, <math dir = "ltr">\displaystyle f(n) \ge f(n)</math>, ולכן <math dir = "ltr">\displaystyle f(n) = O(f(n))</math>; מצד שני, עבור <math dir = "ltr">\displaystyle n \ge 1</math>, <math dir = "ltr">\displaystyle f(n) \le f(n)</math>, ולכן <math dir = "ltr">\displaystyle f(n) = \Omega(f(n))</math>. כפי שראינו מקודם, כותבים זאת <math dir = "ltr">\displaystyle f(n) = \Theta(f(n))</math>.
}}
{{הערה|1 =
בראותך <math dir = "ltr">\displaystyle \Theta(g(n))</math>, עליך להסיק מההקשר האם מדובר בקבוצה או באיבר.}}
▲{{הגדרה|תוכן =
▲הקבוצה <math dir = "ltr">\displaystyle \Theta(g(n))</math> הנה החיתוך של<math dir = "ltr">\displaystyle O(g(n))</math> ו<math dir = "ltr">\displaystyle \Omega(g(n))</math>.
{{הגדרה|תוכן = ▼
▲[[תמונה:theta intuition.png|מרכז|100%|אינטואיציה לתטא.]]
#האם יש הבדל בין <math dir = "ltr">\displaystyle O(1)</math>לבין <math dir = "ltr">\displaystyle \Omega(1)</math>? לא. אם משהו הוא <math dir = "ltr">\displaystyle \Theta(1)</math>, אז עפ"י ההגדרה הוא גם <math dir = "ltr">\displaystyle O(1)</math>. אבל גם אם נאמר לנו רק שהוא <math dir = "ltr">\displaystyle O(1)</math>אנחנו יודעים שהוא <math dir = "ltr">\displaystyle \Theta(1)</math>, משום שכל דבר (שנראה בקורס) הוא <math dir = "ltr">\displaystyle \Omega(1)</math>.}}
{{הארה|1 =
▲'''הסבר אינטואיטיבי''': <math dir = "ltr">\displaystyle f(n)</math> מתנהגת, ב<math dir = "ltr">\displaystyle n</math>-ים גדולים, כ<math dir = "ltr">\displaystyle g(n)</math>.
נתן לראות שיש שתי דרכים לסימון קבוע חיובי כלשהו: <math dir = "ltr">\displaystyle O(1)</math> וכן <math dir = "ltr">\displaystyle \Theta(1)</math>- משעותם זהה. לרוב משתמשים ב<math dir = "ltr">\displaystyle O(1)</math>לצורך כך.
}}
==כללי סדרי גדילה==
|