Download
cse 3358 note set 5 n.
Skip this Video
Loading SlideShow in 5 Seconds..
CSE 3358 Note Set 5 PowerPoint Presentation
Download Presentation
CSE 3358 Note Set 5

CSE 3358 Note Set 5

97 Vues Download Presentation
Télécharger la présentation

CSE 3358 Note Set 5

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. CSE 3358 Note Set 5 Data Structures and Algorithms

  2. Google Chrome http://www.google.com/googlebooks/chrome/#

  3. Complexity of Binary Search intbinarySearch(intarr[], intarrSize, int key) { int lo = 0, mid, hi = arrSize – 1; while (lo <= hi) { mid = (lo + hi) / 2; if (key < arr[mid]) hi = mid – 1; else if (arr[mid] < key) lo = mid + 1; else return mid; } return -1; }

  4. Big - O • How do I know that T(n) = n2 + 100n + log10 n + 1000is O(n2)?

  5. Issues with Big - O • Consider: • T(n) = O(n2). • When might this be essentially useless information?

  6. Big - Ω Definition: The function f(n) is Ω(g(n)) if there exist positive numbers c and N such that f(n) >= c*g(n) for all n >= N. Interconnection with Big-O: f(n) ЄΩ(g(n)) iffg(n) Є O(f(n)).

  7. Big - Θ Definition: f(n) is Θ(g(n)) if there exist positive numbers c1, c2, and N such that c1*g(n) <= f(n) <= c2*g(n) for all n >= N. Sometimes called “tight bounds”. Interconnection with Big-O and Big - Ω: f(n) ЄΘ(g(n)) ifff(n) O(g(n)).

  8. ?