Cache-Efficient Algorithms II
|
|
- Darrell Clark
- 6 years ago
- Views:
Transcription
1 6.172 Performace Egieerig of Software Systems LECTURE 9 Cache-Efficiet Algorithms II Charles E. Leiserso October 7, Charles E. Leiserso 1
2 Ideal-Cache Model Features Two-level hierarchy. Cache size of M bytes. Cache-lie legth of B bytes. Fully associative. Optimal, omisciet replacemet. P M/ B cache lies cache B memory Performace Measures work W (ordiary ruig time). cache misses Q Charles E. Leiserso 2
3 Mergig Two Sorted Arrays void Merge(double *C, double *A, double *B, it a, it b) { while (a>0 && b>0) { if (*A <= *B) { *C++ = *A++; a--; } else { *C++ = *B++; b--; } } while (a>0) { *C++ = *A++; a--; } while (b>0) { *C++ = *B++; b--; } } Charles E. Leiserso 3
4 Mergig Two Sorted Arrays void Merge(double *C, double *A, double *B, it a, it b) { while (a>0 && b>0) { if (*A <= *B) { *C++ = *A++; a--; } else { *C++ = *B++; b--; } } } while (a>0) { *C++ = *A++; a--; } while (b>0) { *C++ = *B++; b--; } Time to merge elemets = Θ() Charles E. Leiserso 4
5 Merge Sort void MergeSort(double *B, double *A, it ) { if (==1) { B[0] = A[0]; } else { double *C = malloc(*sizeof(double)); MergeSort(C, A, /2); MergeSort(C+/2, A+/2, -/2); Merge(B, C, C+/2, /2, -/2); } } Charles E. Leiserso 5
6 Merge Sort void MergeSort(double *B, double *A, it ) { if (==1) { B[0] = A[0]; } else { double *C = malloc(*sizeof(double)); MergeSort(C, A, /2); MergeSort(C+/2, A+/2, -/2); Merge(B, C, C+/2, /2, -/2); } } recursively sort recursively sort merge Charles E. Leiserso 6
7 Work of Merge Sort void MergeSort(double *B, double *A, it ) { if (==1) { B[0] = A[0]; } else { double *C = malloc(*sizeof(double)); MergeSort(C, A, /2); MergeSort(C+/2, A+/2, -/2); Merge(B, C, C+/2, /2, -/2); } } W () = Θ(1) if = 1, 2W (/2) + Θ() otherwise Charles E. Leiserso 7
8 Recursio tree Solve W() = 2W(/2) + Θ() Charles E. Leiserso 8
9 Recursio tree Solve W() = 2W(/2) + Θ(). W() 2010 Charles E. Leiserso 9
10 Recursio tree Solve W() = 2W(/2) + Θ(). W(/2) W(/2) 2010 Charles E. Leiserso 10
11 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 W(/4) W(/4) W(/4) W(/4) 2010 Charles E. Leiserso 11
12 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 /4 /4 /4 /4 Θ(1) 2010 Charles E. Leiserso 12
13 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 h = lg /4 /4 /4 /4 Θ(1) 2010 Charles E. Leiserso 13
14 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 h = lg /4 /4 /4 /4 Θ(1) 2010 Charles E. Leiserso 14
15 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 h = lg /4 /4 /4 /4 Θ(1) 2010 Charles E. Leiserso 15
16 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 h = lg /4 /4 /4 /4 Θ(1) 2010 Charles E. Leiserso 16
17 Recursio tree Solve W() = 2W(/2) + Θ(). /2 /2 h = lg /4 /4 /4 /4 Θ(1) #leaves = Θ() 2010 Charles E. Leiserso 17
18 Recursio tree Solve W() = 2W(/2) + Θ(). h = lg /2 /2 /4 /4 /4 /4 Θ(1) #leaves = Θ() W() Θ( lg ) 2010 Charles E. Leiserso 18
19 Now with Cachig Merge subroutie Merge sort Q() = Θ(/B). Θ(/B) if cm, cost c 1. Q () = 2Q (/2) + Θ(/B) otherwise Charles E. Leiserso 19
20 Recursio tree Q () = Θ(/B) if cm, cost c 1. 2Q (/2) + Θ(/B) otherwise. /B /B h=lg(/cm) /2B /2B /B /4B /4B /4B /4B /B Θ(M/B) #leaves = /cm Q() Θ(/B) Θ((/B) lg(/m)) 2010 Charles E. Leiserso 20
21 Bottom Lie for Merge Sort Q () = Θ(/B) if cm, cost c 1. 2Q (/2) + Θ(/B) otherwise. Θ( (/B) lg(/m) ) For M, we have lg(/m) lg, ad thus W()/Q() Θ(B). For M, we have lg(/m) Θ(1), ad thus W()/Q() Θ(B lg ) Charles E. Leiserso 21
22 Multiway Mergig Idea: Merge R < subarrays with a touramet. R Touramet takes Θ(R) work to produce the first output /R 7 7 lg R 2010 Charles E. Leiserso 22
23 Multiway Mergig Idea: Merge R < subarrays with a touramet. R Touramet takes Θ(R) work to produce the first output /R 7 7 lg R 2010 Charles E. Leiserso 23
24 Multiway Mergig R Idea: Merge R < subarrays with a touramet. Touramet takes Θ(R) work to produce the first output Subsequet outputs cost 6 Θ(lg R) per elemet /R 7 lg R 2010 Charles E. Leiserso 24
25 Multiway Mergig R Idea: Merge R < subarrays with a touramet. Touramet takes Θ(R) work to produce the first output Subsequet outputs cost 6 Θ(lg R) per elemet /R 7 lg R 2010 Charles E. Leiserso 25
26 Multiway Mergig R Idea: Merge R < subarrays with a touramet. Touramet takes Θ(R) work to produce the first output. 28 Subsequet outputs cost 14 Θ(lg R) per elemet /R 7 lg R 7 Total work mergig = Θ(R+ lg R) = Θ( lg R) Charles E. Leiserso 26
27 Multiway Merge Sort W () = Θ(1) if = 1, R W (/R) + Θ( lg R) otherwise. log R recursio tree lg R R (/R) lg R (/R) lg R (/R) lg R R lg R lg R (/R 2 ) lg R (/R 2 ) lg R (/R 2 ) lg R lg R #leaves = Θ(1) Θ() W()= Θ(( lg R) log R +) Same as biary merge sort. = Θ(( lg R)(lg )/lg R+) = Θ( lg ) 2010 Charles E. Leiserso 27
28 Cache Recurrece Assume that R < cm/b for suff. small cost c 1. Cosider the R-way mergig of cotiguous arrays of total size. If R < cm/b, the etire touramet plus 1 block from each array ca fit i cache. Q () Θ(/B). R-way merge sort Θ(/B) if < cm, Q() R Q(/R) + Θ(/B) otherwise Charles E. Leiserso 28
29 Cache Aalysis Q() Θ(/B) if < cm, R Q(/R) + Θ(/B) otherwise. log R (/cm) /BR 2 Θ(M/B) recursio tree /B /BR R /BR /BR 2 /BR 2 R /B /BR /B /B #leaves = /cm Θ(/B) Q() = Θ((/B) log R (/M)) 2010 Charles E. Leiserso 29
30 Tue We have Q () = Θ((/B) log R (/M)), which decreases as R icreases. Choose R as big as possible R = Θ(M/B). By the tall-cache assumptio ad the fact that log (/ M) = Θ((lg )/lg M), we have M Q () = Θ((/B) log M/ B(/ M)) = Θ((/B) log M (/ M)) = Θ(( lg )/B lg M). Hece, we have W()/Q() Θ(B lg M) Charles E. Leiserso 30
31 Multiway versus Biary Merge Sort We have versus Q multiway () = Θ(( lg )/B lg M) Q biary () = Θ((/B) lg (/M)). If M, the lg (/M) lg, ad thus multiway merge sort saves a factor of Θ(lgM) i cache misses. Eample L1-cache: M = 2 15, B = savigs. L2-cache: M = 2 18, B = savigs. L3-cache: M = 2 23, B = savigs Charles E. Leiserso 31
32 Optimal Cache-Oblivious Sortig Fuelsort [FLPR99] 1. Recursively sort 1/3 groups of 2/3 items. 2. Merge the sorted groups with a 1/3 -fuel. A k-fuel merges k 3 items i k sorted lists, icurrig at most cache misses. Thus, fuelsort icurs cache misses, which is asymptotically optimal [AV88] Charles E. Leiserso 32
33 Costructio of a k-fuel Subfuels i cotiguous storage. Buffers i cotiguous storage. Refill buffers o demad. Space = O(k2). buffers k k k3/2 k k k3 items Cache misses = O(k + (k3/b)(1+logmk)) Tall-cache assumptio: M = Ω(B2) Charles E. Leiserso 33
34 Heat Diffusio 2D heat equatio Let u(t,,y) = temperature at time t at poit (,y). u t = α 2 u y u 2 α is the thermal diffusivity. Ackowledgmet These stecil slides were heavily ispired by origials due to Matteo Frigo Charles E. Leiserso 34
35 2D Heat-Diffusio Simulatio Before After 2010 Charles E. Leiserso 35
36 1D Heat Equatio u t 2 α u Charles E. Leiserso 36
37 Fiite-Differece Approimatio 2010 Charles E. Leiserso α u t u, Δ /2) Δ, ( /2) Δ, ( ), ( u t u t t u. ) (Δ ) Δ, ( ), ( 2 ) Δ, ( Δ /2) Δ, )( / ( /2) Δ, )( / ( ), ( 2 2 u t u t u t t u t u t u 2, Δ ), ( ), Δ ( ), ( t u t t u t t t u. ) (Δ ) Δ, ( ), ( 2 ) Δ, ( α Δ ), ( ), Δ ( 2 u t u t u t t u t t u t The 1D heat equatio thus reduces to
38 3-Poit Stecil t Update rule A stecil computatio updates each poit i a array by a fied patter, called a stecil. boudary αδt u[ t + 1][ ] = u[ t][ ] + ( u[ t][ + 1] 2u [ t][ ] + u[ t][ 1]), 2 (Δ) 2010 Charles E. Leiserso 38
39 Cache Behavior of Loopig double u[2][n]; // eve-odd trick static ilie double kerel(double * u) { retur u[0] + ALPHA * (u[-1] - 2*u[0] + u[1]); } for (it t = 1; t < T-1; ++t) { // time loop for(it = 1; < N-1; ++) // space loop u[(t+1)%2][] = kerel( &u[t%2][] ); u Assumig LRU, if N > M, the Q = Θ(NT/B) Charles E. Leiserso 39
40 Cache-Oblivious 3-Poit Stecil t1 t height t0 Recursively traverse trapezoidal regios of space-time poits (t,) such that t0 t < t1 0+d0(t-t0) < 1+d1(t-t0) d0, d1 { 1, 0, 1} width Charles E. Leiserso 40 1
41 Base Case If height = 1, compute all space-time poits i the trapezoid. Ay order of computatio is valid, sice o poit depeds o aother. t 2010 Charles E. Leiserso 41
42 Space Cut If width 2 height, cut the trapezoid with a lie of slope -1 through the ceter. Traverse the trapezoid o the left first, ad the the oe o the right. t 2010 Charles E. Leiserso 42
43 Time Cut If width < 2 height, cut the trapezoid with a horizotal lie through the ceter. Traverse the bottom trapezoid first, ad the the top oe. t 2010 Charles E. Leiserso 43
44 C Implemetatio void trapezoid(it t0, it t1, it 0, it d0, it 1, it d1) { it lt = t1 - t0; if (lt == 1) { for (it = 0; < 1; ++) kerel(t, ); } else if (lt > 1) { if (2 * (1-0) + (d1 - d0) * lt >= 4 * lt) { it m = (2 * (0 + 1) + (2 + d0 + d1) * lt) / 4; trapezoid(t0, t1, 0, d0, m, -1); trapezoid(t0, t1, m, -1, 1, d1); } else { it halflt = lt / 2; trapezoid(t0, t0 + halflt, 0, d0, 1, d1); trapezoid(t0 + halflt, t1, 0 + d0 * halflt, d0, 1 + d1 * halflt, d1); } } } 2010 Charles E. Leiserso 44
45 Cache Aalysis recursio tree Θ(1) W(/2) Θ(1) W(/2) Θ(1) Θ(1) Θ(1) Θ(1) Each leaf represets Θ(hw) poits where h = Θ(w). Each leaf icurs Θ(w/B) misses where w = Θ(M). Θ(NT/hw) leaves. #iteral odes = #leaves - 1 do ot cotribute substatially to Q. Q = Θ(NT/hw) Θ(w/B) = Θ(NT/M 2 ) Θ(M/B) = Θ(NT/MB) Charles E. Leiserso 45
46 Simulatio: 3-Poit Stecil Rectagular regio N = 95 T = 87 Loopig Fully associative LRU cache B = 4 poits M = 32 Cache-hit latecy = 1 cycle Cache-miss latecy = 10 cycles Trapezoid 2010 Charles E. Leiserso 46
47 Loopig v. Trapezoid for Real 2010 Charles E. Leiserso 47
48 Other C-O Algorithms Matri Traspositio/Additio Straightforward recursive algorithm. Θ(1+m/B) Strasse s Algorithm Θ( + 2 /B + lg 7 /BM (lg 7)/2-1 ) Straightforward recursive algorithm. Fast Fourier Trasform Θ(1 + (/B)(1 + log )) M Variat of Cooley-Tukey [CT65] usig cache-oblivious matri traspose. LUP-Decompositio Θ(1 + 2 /B + 3 /BM 1/2 ) Recursive algorithm due to Siva Toledo [T97] Charles E. Leiserso 48
49 C-O Data Structures Ordered-File Maiteace O(1 + (lg 2 )/B) INSERT/DELETE or delete aywhere i file while maitaiig O(1)-sized gaps. Amortized boud [BDFC00], later improved i [BCDFC02]. B-Trees INSERT/DELETE: O(1+logB+1+(lg 2 )/ B) SEARCH: O(1+log B+1 ) TRAVERSE: O(1+k/B) Solutio [BDFC00] with later simplificatios [BDIW02], [BFJ02]. Priority Queues O(1+(1/B)log / (/ )) M B B Fuel-based solutio [BF02]. Geeral scheme based o buffer trees [ABDHMM02] supports INSERT/DELETE Charles E. Leiserso 49
50 MIT OpeCourseWare Performace Egieerig of Software Systems Fall 2010 For iformatio about citig these materials or our Terms of Use, visit:
Plan. Analysis of Multithreaded Algorithms. Plan. Matrix multiplication. University of Western Ontario, London, Ontario (Canada) Marc Moreno Maza
Pla Aalysis of Multithreaded Algorithms Marc Moreo Maza Uiversity of Wester Otario, Lodo, Otario (Caada) CS4402-9535 1 2 3 Pla (Moreo Maza) Aalysis of Multithreaded Algorithms CS4402-9535 1 / 27 (Moreo
More informationCO Algorithms: Brief History
Piyush Kumar Departmet of Computer Sciece Advisor: Joseph S.B. Mitchell CO Algorithms: Brief History Frigo, Leiserso, Prokop, Ramachadra (FOCS 99) Cache Oblivious Algorithms Thesis Harold Prokop s Thesis
More informationMerge and Quick Sort
Merge ad Quick Sort Merge Sort Merge Sort Tree Implemetatio Quick Sort Pivot Item Radomized Quick Sort Adapted from: Goodrich ad Tamassia, Data Structures ad Algorithms i Java, Joh Wiley & So (1998). Ruig
More informationCS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides
CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis
More informationCS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2
Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.
More informationThis Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2
This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is
More informationIntroduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication
Itroductio to Algorithms 6.046J/8.40J LECTURE 3 Divide ad coquer Biary search Powerig a umber Fiboacci umbers Matrix multiplicatio Strasse s algorithm VLSI tree layout Prof. Charles E. Leiserso The divide-ad-coquer
More informationSorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.
Sortig Algorithms Algorithms Kyuseo Shim SoEECS, SNU. Desigig Algorithms Icremetal approaches Divide-ad-Coquer approaches Dyamic programmig approaches Greedy approaches Radomized approaches You are ot
More informationClassification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)
Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:
More informationAnalysis of Algorithms -Quicksort-
Aalysis of Algorithms -- Adreas Ermedahl MRTC (Mälardales Real-Time Research Ceter) adreas.ermedahl@mdh.se Autum 2004 Proposed by C.A.R. Hoare i 962 Worst- case ruig time: Θ( 2 ) Expected ruig time: Θ(
More informationData Structures and Algorithm. Xiaoqing Zheng
Data Structures ad Algorithm Xiaoqig Zheg zhegxq@fudaeduc What are algorithms? A sequece of computatioal steps that trasform the iput ito the output Sortig problem: Iput: A sequece of umbers
More informationData Structures Lecture 9
Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to
More informationData Structures and Algorithms
Data Structures ad Algorithms Autum 2017-2018 Outlie 1 Sortig Algorithms (cotd) Outlie Sortig Algorithms (cotd) 1 Sortig Algorithms (cotd) Heapsort Sortig Algorithms (cotd) Have see that we ca build a
More informationCS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)
1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,
More informationCS / MCS 401 Homework 3 grader solutions
CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of
More informationAlgorithms and Data Structures Lecture IV
Algorithms ad Data Structures Lecture IV Simoas Šalteis Aalborg Uiversity simas@cs.auc.dk September 5, 00 1 This Lecture Aalyzig the ruig time of recursive algorithms (such as divide-ad-coquer) Writig
More informationA recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.
CS23 Algorithms Hadout #6 Prof Ly Turbak September 8, 200 Wellesley College RECURRENCES This hadout summarizes highlights of CLRS Chapter 4 ad Appedix A (CLR Chapters 3 & 4) Two-Step Strategy for Aalyzig
More informationCIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5
CIS 11 Data Structures ad Algorithms with Java Sprig 019 Code Sippets ad Recurreces Moday, February 4/Tuesday, February 5 Learig Goals Practice provig asymptotic bouds with code sippets Practice solvig
More informationDivide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.
Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem
More information4.3 Growth Rates of Solutions to Recurrences
4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.
More informationOPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES
OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES Peter M. Maurer Why Hashig is θ(). As i biary search, hashig assumes that keys are stored i a array which is idexed by a iteger. However, hashig attempts to bypass
More informationModel of Computation and Runtime Analysis
Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map
More informationAlgorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources
Algorithm Aalysis Algorithms that are equally correct ca vary i their utilizatio of computatioal resources time ad memory a slow program it is likely ot to be used a program that demads too much memory
More information) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È
Algorithms Professor Joh Reif ALG 1.3 Determiistic Selectio ad Sortig: (a) Selectio Algorithms ad Lower Bouds (b) Sortig Algorithms ad Lower Bouds Problem P size fi divide ito subproblems size 1,..., k
More informationAlgorithm Analysis. Chapter 3
Data Structures Dr Ahmed Rafat Abas Computer Sciece Dept, Faculty of Computer ad Iformatio, Zagazig Uiversity arabas@zu.edu.eg http://www.arsaliem.faculty.zu.edu.eg/ Algorithm Aalysis Chapter 3 3. Itroductio
More informationDynamic Programming. Sequence Of Decisions
Dyamic Programmig Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. Sequece Of Decisios As i the greedy method, the solutio
More informationDynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions
Dyamic Programmig Sequece Of Decisios Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. As i the greedy method, the solutio
More informationAlgorithms Design & Analysis. Divide & Conquer
Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised
More informationCS 5150/6150: Assignment 1 Due: Sep 23, 2010
CS 5150/6150: Assigmet 1 Due: Sep 23, 2010 Wei Liu September 24, 2010 Q1: (1) Usig master theorem: a = 7, b = 4, f() = O(). Because f() = log b a ε holds whe ε = log b a = log 4 7, we ca apply the first
More informationCSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions
CSE 09/09 Topics i ig Data Aalytics Sprig 2017; Homework 1 Solutios Note: Solutios to problems,, ad 6 are due to Marius Nicolae. 1. Cosider the followig algorithm: for i := 1 to α log e do Pick a radom
More informationECE4270 Fundamentals of DSP. Lecture 2 Discrete-Time Signals and Systems & Difference Equations. Overview of Lecture 2. More Discrete-Time Systems
ECE4270 Fudametals of DSP Lecture 2 Discrete-Time Sigals ad Systems & Differece Equatios School of ECE Ceter for Sigal ad Iformatio Processig Georgia Istitute of Techology Overview of Lecture 2 Aoucemet
More informationModel of Computation and Runtime Analysis
Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map
More informationAlgorithms. Elementary Sorting. Dong Kyue Kim Hanyang University
Algorithms Elemetary Sortig Dog Kyue Kim Hayag Uiversity dqkim@hayag.a.kr Cotets Sortig problem Elemetary sortig algorithms Isertio sort Merge sort Seletio sort Bubble sort Sortig problem Iput A sequee
More informationDesign and Analysis of Algorithms
Desig ad Aalysis of Algorithms CSE 53 Lecture 9 Media ad Order Statistics Juzhou Huag, Ph.D. Departmet of Computer Sciece ad Egieerig Dept. CSE, UT Arligto CSE53 Desig ad Aalysis of Algorithms Medias ad
More informationTest One (Answer Key)
CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)
More informationAdvanced Course of Algorithm Design and Analysis
Differet complexity measures Advaced Course of Algorithm Desig ad Aalysis Asymptotic complexity Big-Oh otatio Properties of O otatio Aalysis of simple algorithms A algorithm may may have differet executio
More informationChapter 2. Asymptotic Notation
Asyptotic Notatio 3 Chapter Asyptotic Notatio Goal : To siplify the aalysis of ruig tie by gettig rid of details which ay be affected by specific ipleetatio ad hardware. [1] The Big Oh (O-Notatio) : It
More informationCSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN
CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.5703) ALGORITHM ANALYSIS AND DESIGN (3 cr.) (T) Topics of curret iterest i the desig ad aalysis of computer algorithms for graphtheoretical
More informationExamples: data compression, path-finding, game-playing, scheduling, bin packing
Algorithms - Basic Cocepts Algorithms so what is a algorithm, ayway? The dictioary defiitio: A algorithm is a well-defied computatioal procedure that takes iput ad produces output. This class will deal
More informationECE 669 Parallel Computer Architecture
ECE 669 Parallel Computer Architecture Lecture 4 Parallel Applicatios Outlie Motivatig Problems (applicatio case studies) Classifyig problems Parallelizig applicatios Examiig tradeoffs Uderstadig commuicatio
More informationSums, products and sequences
Sums, products ad sequeces How to write log sums, e.g., 1+2+ (-1)+ cocisely? i=1 Sum otatio ( sum from 1 to ): i 3 = 1 + 2 + + If =3, i=1 i = 1+2+3=6. The ame ii does ot matter. Could use aother letter
More informationRecursive Algorithm for Generating Partitions of an Integer. 1 Preliminary
Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the
More informationAlgorithms 演算法. Multi-threaded Algorithms
演算法 Multi-threaded Professor Chie-Mo James Li 李建模 Graduate Istitute of Electroics Egieerig Natioal aiwa Uiversity Outlie Multithreaded, CH7 7. Basics 7. Matrix Multiplicatio 7.3 Merge sort Leoardo Fiboacci
More informationLecture 3: Asymptotic Analysis + Recurrences
Lecture 3: Asymptotic Aalysis + Recurreces Data Structures ad Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Write a model ad fid Big-O for (it i = 0; i < ; i++) { for (it j = 0; j < i; j++) { System.out.pritl(
More informationFilter banks. Separately, the lowpass and highpass filters are not invertible. removes the highest frequency 1/ 2and
Filter bas Separately, the lowpass ad highpass filters are ot ivertible T removes the highest frequecy / ad removes the lowest frequecy Together these filters separate the sigal ito low-frequecy ad high-frequecy
More informationPC5215 Numerical Recipes with Applications - Review Problems
PC55 Numerical Recipes with Applicatios - Review Problems Give the IEEE 754 sigle precisio bit patter (biary or he format) of the followig umbers: 0 0 05 00 0 00 Note that it has 8 bits for the epoet,
More informationLecture 3: Divide and Conquer: Fast Fourier Transform
Lecture 3: Divide ad Coquer: Fast Fourier Trasform Polyomial Operatios vs. Represetatios Divide ad Coquer Algorithm Collapsig Samples / Roots of Uity FFT, IFFT, ad Polyomial Multiplicatio Polyomial operatios
More informationAverage-Case Analysis of QuickSort
Average-Case Aalysis of QuickSort Comp 363 Fall Semester 003 October 3, 003 The purpose of this documet is to itroduce the idea of usig recurrece relatios to do average-case aalysis. The average-case ruig
More informationThe picture in figure 1.1 helps us to see that the area represents the distance traveled. Figure 1: Area represents distance travelled
1 Lecture : Area Area ad distace traveled Approximatig area by rectagles Summatio The area uder a parabola 1.1 Area ad distace Suppose we have the followig iformatio about the velocity of a particle, how
More informationAnalysis of Multithreaded Algorithms
Analysis of Multithreaded Algorithms Marc Moreno Maza University of Western Ontario, London, Ontario (Canada) CS 4435 - CS 9624 (Moreno Maza) Analysis of Multithreaded Algorithms CS 4435 - CS 9624 1 /
More informationDivide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016
COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Lecturer: Debmalya Paigrahi Divide ad Coquer Scribe: Tiaqi Sog 1 Overview I this lecture, a importat algorithm desig techique called divide-ad-coquer
More informationRecurrence Relations
Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The
More informationIP Reference guide for integer programming formulations.
IP Referece guide for iteger programmig formulatios. by James B. Orli for 15.053 ad 15.058 This documet is iteded as a compact (or relatively compact) guide to the formulatio of iteger programs. For more
More informationDepartment of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:
Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch Iformatik II Midterm1 Sprig 018 3.03.018 Advice You have 90 miutes to complete
More information15.081J/6.251J Introduction to Mathematical Programming. Lecture 21: Primal Barrier Interior Point Algorithm
508J/65J Itroductio to Mathematical Programmig Lecture : Primal Barrier Iterior Poit Algorithm Outlie Barrier Methods Slide The Cetral Path 3 Approximatig the Cetral Path 4 The Primal Barrier Algorithm
More informationRecursive Algorithms. Recurrences. Recursive Algorithms Analysis
Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects
More information6.003 Homework #3 Solutions
6.00 Homework # Solutios Problems. Complex umbers a. Evaluate the real ad imagiary parts of j j. π/ Real part = Imagiary part = 0 e Euler s formula says that j = e jπ/, so jπ/ j π/ j j = e = e. Thus the
More informationDisjoint set (Union-Find)
CS124 Lecture 7 Fall 2018 Disjoit set (Uio-Fid) For Kruskal s algorithm for the miimum spaig tree problem, we foud that we eeded a data structure for maitaiig a collectio of disjoit sets. That is, we eed
More informationHonors Calculus Homework 13 Solutions, due 12/8/5
Hoors Calculus Homework Solutios, due /8/5 Questio Let a regio R i the plae be bouded by the curves y = 5 ad = 5y y. Sketch the regio R. The two curves meet where both equatios hold at oce, so where: y
More informationIntroduction to Algorithms
Itroductio to Algorithms 6.046J/8.40J/SMA5503 Lecture 9 Pro. Charles E. Leiserso Biary-search-tree sort T Create a empty BST or i to do TREE-INSERT(T, A[i]) Perorm a iorder tree wal o T. Eample: A [3 8
More informationIntroduction to Algorithms
Itroductio to Algorithms 6.046J/8.40J LECTURE 9 Radomly built biary search trees Epected ode depth Aalyzig height Coveity lemma Jese s iequality Epoetial height Post mortem Pro. Eri Demaie October 7, 2005
More informationITEC 360 Data Structures and Analysis of Algorithms Spring for n 1
ITEC 360 Data Structures ad Aalysis of Algorithms Sprig 006 1. Prove that f () = 60 + 5 + 1 is Θ ( ). 60 + 5 + 1 60 + 5 + = 66 for 1 Take C 1 = 66 f () = 60 + 5 + 1 is O( ) Sice 60 + 5 + 1 60 for 1 If
More informationTMA4205 Numerical Linear Algebra. The Poisson problem in R 2 : diagonalization methods
TMA4205 Numerical Liear Algebra The Poisso problem i R 2 : diagoalizatio methods September 3, 2007 c Eiar M Røquist Departmet of Mathematical Scieces NTNU, N-749 Trodheim, Norway All rights reserved A
More informationMatriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:
Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch AlgoDat Midterm1 Sprig 016 08.04.016 Name: Matriculatio umber: Advice You have
More informationCSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)
CSI 101 Discrete Structures Witer 01 Prof. Lucia Moura Uiversity of Ottawa Homework Assigmet #4 (100 poits, weight %) Due: Thursday, April, at 1:00pm (i lecture) Program verificatio, Recurrece Relatios
More informationMerge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1)
Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort versio 1.3 1 Outlie d Redig Divide-d-coquer prdigm ( 4.1.1 Merge-sort ( 4.1.1 Algorithm Mergig two sorted sequeces Merge-sort tree
More informationSkip Lists. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 S 3 S S 1
Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Skip Lists S 3 15 15 23 10 15 23 36 Skip Lists 1 What is a Skip List A skip list for
More informationDesign and Analysis of ALGORITHM (Topic 2)
DR. Gatot F. Hertoo, MSc. Desig ad Aalysis of ALGORITHM (Topic 2) Algorithms + Data Structures = Programs Lessos Leared 1 Our Machie Model: Assumptios Geeric Radom Access Machie (RAM) Executes operatios
More informationQuestion1 Multiple choices (circle the most appropriate one):
Philadelphia Uiversity Studet Name: Faculty of Egieerig Studet Number: Dept. of Computer Egieerig Fial Exam, First Semester: 2014/2015 Course Title: Digital Sigal Aalysis ad Processig Date: 01/02/2015
More information+ au n+1 + bu n = 0.)
Lecture 6 Recurreces - kth order: u +k + a u +k +... a k u k 0 where a... a k are give costats, u 0... u k are startig coditios. (Simple case: u + au + + bu 0.) How to solve explicitly - first, write characteristic
More information5.1 Review of Singular Value Decomposition (SVD)
MGMT 69000: Topics i High-dimesioal Data Aalysis Falll 06 Lecture 5: Spectral Clusterig: Overview (cotd) ad Aalysis Lecturer: Jiamig Xu Scribe: Adarsh Barik, Taotao He, September 3, 06 Outlie Review of
More informationCOMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro
COMP60: Itroduig Complexity Aalysis (08/9) Luas Cordeiro luas.ordeiro@mahester.a.uk Itroduig Complexity Aalysis Textbook: Algorithm Desig ad Appliatios, Goodrih, Mihael T. ad Roberto Tamassia (hapter )
More informationLet A(x) and B(x) be two polynomials of degree n 1:
MI-EVY (2011/2012) J. Holub: 4. DFT, FFT ad Patter Matchig p. 2/42 Operatios o polyomials MI-EVY (2011/2012) J. Holub: 4. DFT, FFT ad Patter Matchig p. 4/42 Efficiet Patter Matchig (MI-EVY) 4. DFT, FFT
More information6.046 Recitation 5: Binary Search Trees Bill Thies, Fall 2004 Outline
6.046 Recitatio 5: Biary Search Trees Bill Thies, Fall 2004 Outlie My cotact iformatio: Bill Thies thies@mit.edu Office hours: Sat 1-3pm, 36-153 Recitatio website: http://cag.lcs.mit.edu/~thies/6.046/
More informationContext-free grammars and. Basics of string generation methods
Cotext-free grammars ad laguages Basics of strig geeratio methods What s so great about regular expressios? A regular expressio is a strig represetatio of a regular laguage This allows the storig a whole
More informationMassachusetts Institute of Technology
6.0/6.3: Probabilistic Systems Aalysis (Fall 00) Problem Set 8: Solutios. (a) We cosider a Markov chai with states 0,,, 3,, 5, where state i idicates that there are i shoes available at the frot door i
More informationQuantum Computing Lecture 7. Quantum Factoring
Quatum Computig Lecture 7 Quatum Factorig Maris Ozols Quatum factorig A polyomial time quatum algorithm for factorig umbers was published by Peter Shor i 1994. Polyomial time meas that the umber of gates
More informationLog1 Contest Round 1 Theta Equations & Inequalities. 4 points each. 5 points each. 7, a c d. 9, find the value of the product abcd.
013 01 Log1 Cotest Roud 1 Theta Equatios & Iequalities Name: poits each 1 Solve for x : x 3 38 Fid the greatest itegral value of x satisfyig the iequality x x 3 7 1 3 3 xy71 Fid the ordered pair solutio
More information15.083J/6.859J Integer Optimization. Lecture 3: Methods to enhance formulations
15.083J/6.859J Iteger Optimizatio Lecture 3: Methods to ehace formulatios 1 Outlie Polyhedral review Slide 1 Methods to geerate valid iequalities Methods to geerate facet defiig iequalities Polyhedral
More informationCache Oblivious Stencil Computations
Cache Oblivious Stencil Computations S. HUNOLD J. L. TRÄFF F. VERSACI Lectures on High Performance Computing 13 April 2015 F. Versaci (TU Wien) Cache Oblivious Stencil Computations 13 April 2015 1 / 19
More informationCSE 332. Data Structures and Parallelism
Aam Blak Lecture 6a Witer 2017 CSE 332 Data Structures a Parallelism CSE 332: Data Structures a Parallelism More Recurreces T () T (/2) T (/2) T (/4) T (/4) T (/4) T (/4) P1 De-Brief 1 You i somethig substatial!
More informationMaximum and Minimum Values
Sec 4.1 Maimum ad Miimum Values A. Absolute Maimum or Miimum / Etreme Values A fuctio Similarly, f has a Absolute Maimum at c if c f f has a Absolute Miimum at c if c f f for every poit i the domai. f
More informationSolutions to quizzes Math Spring 2007
to quizzes Math 4- Sprig 7 Name: Sectio:. Quiz a) x + x dx b) l x dx a) x + dx x x / + x / dx (/3)x 3/ + x / + c. b) Set u l x, dv dx. The du /x ad v x. By Itegratio by Parts, x(/x)dx x l x x + c. l x
More informationECEN 655: Advanced Channel Coding Spring Lecture 7 02/04/14. Belief propagation is exact on tree-structured factor graphs.
ECEN 655: Advaced Chael Codig Sprig 014 Prof. Hery Pfister Lecture 7 0/04/14 Scribe: Megke Lia 1 4-Cycles i Gallager s Esemble What we already kow: Belief propagatio is exact o tree-structured factor graphs.
More informationOptimization Methods MIT 2.098/6.255/ Final exam
Optimizatio Methods MIT 2.098/6.255/15.093 Fial exam Date Give: December 19th, 2006 P1. [30 pts] Classify the followig statemets as true or false. All aswers must be well-justified, either through a short
More informationLecture 2: Finite Difference Methods in Heat Transfer
Lecture 2: Fiite Differece Methods i Heat Trasfer V.Vuorie Aalto Uiversity School of Egieerig Heat ad Mass Trasfer Course, Autum 2016 November 1 st 2017, Otaiemi ville.vuorie@aalto.fi Overview Part 1 (
More informationCS 332: Algorithms. Quicksort
CS 33: Aorithms Quicsort David Luebe //03 Homewor Assiged today, due ext Wedesday Will be o web page shortly after class Go over ow David Luebe //03 Review: Quicsort Sorts i place Sorts O( ) i the average
More informationCache-Oblivious Algorithms
Cache-Oblivious Algorithms 1 Cache-Oblivious Model 2 The Unknown Machine Algorithm C program gcc Object code linux Execution Can be executed on machines with a specific class of CPUs Algorithm Java program
More informationCache-Oblivious Algorithms
Cache-Oblivious Algorithms 1 Cache-Oblivious Model 2 The Unknown Machine Algorithm C program gcc Object code linux Execution Can be executed on machines with a specific class of CPUs Algorithm Java program
More informationCh3. Asymptotic Notation
Ch. Asymptotic Notatio copyright 006 Preview of Chapters Chapter How to aalyze the space ad time complexities of program Chapter Review asymptotic otatios such as O, Ω, Θ, o for simplifyig the aalysis
More informationLecture 16: Monotone Formula Lower Bounds via Graph Entropy. 2 Monotone Formula Lower Bounds via Graph Entropy
15-859: Iformatio Theory ad Applicatios i TCS CMU: Sprig 2013 Lecture 16: Mootoe Formula Lower Bouds via Graph Etropy March 26, 2013 Lecturer: Mahdi Cheraghchi Scribe: Shashak Sigh 1 Recap Graph Etropy:
More informationMath 312 Lecture Notes One Dimensional Maps
Math 312 Lecture Notes Oe Dimesioal Maps Warre Weckesser Departmet of Mathematics Colgate Uiversity 21-23 February 25 A Example We begi with the simplest model of populatio growth. Suppose, for example,
More informationCS161 Design and Analysis of Algorithms. Administrative
CS161 Desig ad Aalysis of Algorithms Da Boeh 1 Admiistrative Lecture 1, April 3, 1 Web page http://theory.staford.edu/~dabo/cs161» Hadouts» Aoucemets» Late breakig ews Gradig ad course requiremets» Midterm/fial/hw»
More informationCourse : Algebraic Combinatorics
Course 8.32: Algebraic Combiatorics Lecture Notes # Addedum by Gregg Musier February 4th - 6th, 2009 Recurrece Relatios ad Geeratig Fuctios Give a ifiite sequece of umbers, a geeratig fuctio is a compact
More informationProblem Cosider the curve give parametrically as x = si t ad y = + cos t for» t» ß: (a) Describe the path this traverses: Where does it start (whe t =
Mathematics Summer Wilso Fial Exam August 8, ANSWERS Problem 1 (a) Fid the solutio to y +x y = e x x that satisfies y() = 5 : This is already i the form we used for a first order liear differetial equatio,
More informationMath E-21b Spring 2018 Homework #2
Math E- Sprig 08 Homework # Prolems due Thursday, Feruary 8: Sectio : y = + 7 8 Fid the iverse of the liear trasformatio [That is, solve for, i terms of y, y ] y = + 0 Cosider the circular face i the accompayig
More informationFundamental Algorithms
Fudametal Algorithms Chapter 2b: Recurreces Michael Bader Witer 2014/15 Chapter 2b: Recurreces, Witer 2014/15 1 Recurreces Defiitio A recurrece is a (i-equality that defies (or characterizes a fuctio i
More informationSolutions to Final Exam Review Problems
. Let f(x) 4+x. Solutios to Fial Exam Review Problems Math 5C, Witer 2007 (a) Fid the Maclauri series for f(x), ad compute its radius of covergece. Solutio. f(x) 4( ( x/4)) ( x/4) ( ) 4 4 + x. Sice the
More informationPolynomial Multiplication and Fast Fourier Transform
Polyomial Multiplicatio ad Fast Fourier Trasform Com S 477/577 Notes Ya-Bi Jia Sep 19, 2017 I this lecture we will describe the famous algorithm of fast Fourier trasform FFT, which has revolutioized digital
More informationCS434a/541a: Pattern Recognition Prof. Olga Veksler. Lecture 5
CS434a/54a: Patter Recogitio Prof. Olga Veksler Lecture 5 Today Itroductio to parameter estimatio Two methods for parameter estimatio Maimum Likelihood Estimatio Bayesia Estimatio Itroducto Bayesia Decisio
More information