1 / 8

CSE 3358 Note Set 5

CSE 3358 Note Set 5. Data Structures and Algorithms. Google Chrome. http://www.google.com/googlebooks/chrome/#. Complexity of Binary Search. int binarySearch ( int arr [], int arrSize , int key) { int lo = 0, mid, hi = arrSize – 1; while (lo <= hi) { mid = (lo + hi) / 2;

ouida
Télécharger la présentation

CSE 3358 Note Set 5

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. 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. ?

More Related