This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: ALGORITHM TYPES • Greedy, Divide and Conquer, Dynamic Programming, Random Algorithms, and Backtracking. • Note the general strategy from the examples. • The classification is neither exhaustive (there may be more) nor mutually exclusive (one may combine). • We are now emphasizing design of algorithms, not data structures. GREEDY: Some Scheduling problems • Scheduling Algorithm: Optimizing function is aggregate finishtime with one processor • (jobid, duration pairs)::(j1, 15), (j2, 8), (j3, 3), (j4, 10): aggregate FT in this order is 15+23+26+36=100 • Note: durations of tasks are getting added multiple times: 15 + (15+8) + ((15+8) + 3) + . . . • Optimal schedule is the Greedy schedule: j3, j2, j4, j1. Aggregate FT=3+11+21+36=71 [Let the lower values get added more times: shortest job first ] • Sort: O (n log n) , + Placing: Θ (n), • Total: O(n log n) , MULTIPROCESSOR SCHEDULING (Aggregate FT) • Optimizing Fn. Aggregate FT  Strategy: Assign preordered jobs over processors one by one • Input (jobid, duration)::(j2, 5), (j1, 3), (j5, 11), (j3, 6), (j4, 10), (j8, 18), (j6, 14), (j7, 15), (j9, 20): 3 proc • Sort first: (j1, 3), (j2, 5), (j3, 6), (j4, 10), (j5, 11), (j6, 14), (j7, 15), (j8, 18), (j9, 20) // O (n log n) • Schedule next job on earliest available processor • Proc 1: j1, j4, j7 Proc 2: j2, j5, j8 Proc 3: j3, j6, j9 // Sort: Theta(n log n), Place: Theta(n), Total: Theta(n log n) • Note the first task is to order jobs for a “greedy” pick up • Optimizing Fn. Last FT  Strategy: Sort jobs in reverse order, assign next job on the earliest available processor • (j3, 6), (j1, 3), (j2, 5), (j4, 10), (j6, 14), (j5, 11), (j8, 18), (j7, 15), (j9, 20): 3 proc • Reverse sort • (j9, 20), (j8, 18), (j7, 15), (j6, 14), (j5, 11), (j4, 10), (j3, 6), (j2, 5), (j1, 3) • Proc 1: j9  20, j4  30, j1  33. • Proc 2: j8  18, j5  29, j3  35, • Proc 3: j7  15, j6  29, j2  34, Last FT = 35. • // sort: O(n log n) • // place: naïve: Θ (nM), with heap over processors: O (n log m) • Optimal: Proc1: j2, j5, j8; Proc 2: j6, j9; Proc 3: j1, j3, j4, j7. Last FT = 34. • Greedy alg is not optimal algorithm here, but the relative err <= [1/3  1/3m], for m processors. • An NPcomplete problem, greedy alg is polynomial O(n logn) for n jobs (from sorting, assignment is additional O(n), choice of next proc. In each cycle O(log m) using heap, total O(n logn + n logm), for n>>m the first term dominates). MULTIPROCESSOR SCHEDULING (Last FT) HUFFMAN CODES • Problem: device a (binary) coding of alphabets for a text, given their frequency in the text, such that the total number of bits in the translation is minimum....
View
Full
Document
This note was uploaded on 02/10/2012 for the course CSE 5211 taught by Professor Dmitra during the Spring '12 term at FIT.
 Spring '12
 Dmitra
 Algorithms, C Programming

Click to edit the document details