This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: a. distance check for a given vertex updated is O(1) 3. array length n for previous vertex 4. Fringe: WHAT STRUCTURE? 5. stack to determine path Worst case analysis of running time things to count toward running time 1. add (A) vertex to fringe 2. pick (P) minimum distance vertex from fringe 3. check (C) neighbors for distance 4. update (U) neighbors distance version 1: fringe is an unsorted linked list -- O(n 2 ) A: all vertices added to fringe in O(n) [each is added to front, O(1)] P: O(n 2 ) best case: A - B - C - D -E worst case: 1. start with n-1 vertices in fringe 2. each pick gets last in LL (n-1)+(n-2)++1 = O(n 2 ) C: how many distance checks? e -- each check is O(1) time since distance are in array, indexable by vertex number. overall, O(e) U: worst possible number is e - every check results in update: O(e) [each update O(1), just like check]...
View Full Document
This note was uploaded on 03/29/2012 for the course CS 112 taught by Professor Sesh during the Spring '07 term at Rutgers.
- Spring '07
- Data Structures