Presentation is loading. Please wait.

Presentation is loading. Please wait.

Growth of Functions: Asymptotic Notations Direct Address Tables Hashing.

Similar presentations


Presentation on theme: "Growth of Functions: Asymptotic Notations Direct Address Tables Hashing."— Presentation transcript:

1 Growth of Functions: Asymptotic Notations Direct Address Tables Hashing

2 מושגים O   (Asymptotic Notation) הגדרה : T(n)=O(g(n)) אם קיים n 0 וקבוע C>0 כך שלכל n  n 0 מתקיים T(n)  Cg(n) דוגמא : 4n100+=O(n) 4n+100  Cn C  4+100/n n 0 =100, C=5

3 מושגים O   מהו הנכון ? 3n+1 = O(n 2 ) (n+1) 2 =O(n 2 ) (n+1) 2 =O(n) 8=O(1) log(n)=O(n) nlog(n)=O(n)

4 מושגים O   (Asymptotic Notation) הגדרה : T(n)=  (g(n)) אם קיים n 0 וקבוע C>0 כך שלכל n  n 0 מתקיים T(n)  Cg(n) דוגמא : 4n100+=  (n) 4n+100  Cn C  4+100/n n 0 =1, C=4

5 מושגים O   מהו הנכון ? 3n+1 =  (n 2 ) (n+1) 2 =  (n 2 ) (n+1) 2 =  (n) 8=  (1) log(n)=  (n) nlog(n)=  (n)

6 מושגים O   (Asymptotic Notation) הגדרה : T(n)=  (g(n)) אם קיים n 0 וקבועים C 1,C 2 >0 כך שלכל n  n 0 מתקיים C 1 g(n)  T(n)  C 2 g(n) דוגמא : 4n100+=  (n) C 1 n  4n+100  C 2 n C 2  4+100/n C 1  4+100/n n 0 =100, C 2 =5, C 1 =4

7 מושגים O   מהו הנכון ? 3n+1 =  (n 2 ) (n+1) 2 =  (n 2 ) (n+1) 2 =  (n) 8=  (1) log(n)=  (n) nlog(n)=  (n)

8 תכונות של O   A={O   } 1) Transitivity: if f(n)=A(g(n)) and g(n)=A(h(n)) then f(n)=A(h(n)) 2) Reflexivity: f(n)=A(f(n)) 3) Symmetry: if f(n)=  (g(n)) then g(n)=  (f(n)) 3’) Transpose symmetry: if f(n)= O(g(n)) then g(n)=  (h(n))

9 דוגמא :

10

11 דוגמא : פעולות על רשימה. זמני ריצה L={x 1,x 2,…, x n } ListSearch(value):Ptr Ptr x  Head() While (not Outside(x)) and Key(x) <> value x  Next(x)(worst case:) If Outside(x)  (n) Return nil Else Return x


Download ppt "Growth of Functions: Asymptotic Notations Direct Address Tables Hashing."

Similar presentations


Ads by Google