Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Size: px
Start display at page:

Download "Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016"

Transcription

1 COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Divide ad Coquer Lecturer: Debmalya Paigrahi Scribe: Tiaqi Sog, Tiayu Wag 1 Overview This set of otes is orgaized as follows. We begi by itroducig a O( 2 ) sortig algorithm, which motivates the cocept of divide ad coquer by itroducig QuickSort. We the proceed by aalyzig three more examples: merge sort, bit-strig multiplicatio, polyomial multiplicatio ad a O()-time algorithm for the problem of selectio. We coclude by itroducig the master theorem method for solvig recurrece relatios. 1 2 Isertio Sort We ow ivestigate a simple sortig algorithm. Algorithm 1 Isertio sort 1: fuctio INS-SORT(A[1...],k) 2: for i 1 to do 3: INSERT(A[1,...,i 1],i) assume INSERT iserts A[i] ito sorted positio i A[1,...,i 1] ad takes O(i) time. 4: retur A[1,...,] A recurrece relatio for Algorithm 1 is We aalyze the ruig time by computatio tree: T () = T ( 1) + O(). O() O(-1) -1 O(-2) -2 We have 1 Some of the material i this ote is from previous otes by Samuel Haey, Yilu Zhou ad Nat Kell for this class i Fall

2 T () = O() + O( 1) + O( 2) O(1) = O( 2 ) Next, we show that we ca desig a faster sortig algorithm by divide-ad-coquer techique. 3 QuickSort I the followig algorithm, A is the uderlyig array/list; r,l are rightmost (largest), ad leftmost (smallest) idices respectively. 3.1 The algorithm Algorithm 2 QuickSort(A, l,r) 1: m Pivot(A,l,r) 2: Swap(A, l, m) 3: QuickSort(A,l,m 1) 4: QuickSort(A,m + 1,r) The Swap(A,i, j) fuctio just swap the values A[i] ad A[ j]. The Pivot fuctio is described i the followig sectio. 3.2 Pickig a pivot poit A pivot poit is the poit from where we divide the QuickSort ito two subproblems. Below is a algorithm for pickig a pivot poit. Algorithm 3 Pivot(A, l,r) 1: i l, j r + 1, x A[i], 2: while i < j do 3: Repeat i + + util x A[i] 4: Repeat j util x A[ j] 5: Swap(A,i, j) 6: Retur j Therefore, the recurrece relatio for QuickSort is T () = O() + T (i) + T ( i) where i is the chose pivot poit. I the worst case, where i = 1 or i = 1, T () = T ( 1) + O() = O( 2 ). I the best case, where i = 2, T () = 2T ( 2 ) + O() = O(log). 3.3 Extesio Radomly pickig a pivot poit I practice, we ofte radomly pickig a pivot poit with the followig procedure iserted before pickig a pivot. The modified versio is ofte referred to as Radomized QuickSort. 2-2

3 Algorithm 4 R-Select(A, l,r) 1: i Radom(l,r) 2: Swap(A, i, l) Here the Radom(l, r) fuctio uiformly radomly geerates a iteger that is betwee l ad r. The aalysis of the radomized QuickSort is beyod the scope of this course. With this trick, the expected ruig time is O(log). 4 Mergesort 4.1 Itroductio Mergesort is a sortig algorithm with both worst-case ad average-case performace of O( log ). The algorithm is also a recursive divide-ad-coquer alillustrategorithm, but istead of usig a pivot to decide where to partitio our subproblems, mergesort always divides the array equally. Mergesort the recursively sorts these two subarrays ad the combies (or merges) them ito oe master sorted array. 4.2 Pseudocode 1 // Msort(A,i,j) will sort elemet A[i] through A[j] i A 2 Msort(A,i,j) 3 B=Msort(A,i,(i+j)/2) 4 C=Msort(A,(i+j)/2+1,j) 5 A=merge(B,C) 6 7 // Merge(B,C) assumes sorted arrays B ad C 8 // ad merges them ito oe big sorted array 9 Merge(B,C) 10 D=empty array 11 i=j=k=1 12 while(i< B ad j< C ) 13 if(b[i]<c[j]) the D[k]=B[i], i++ 14 else the D[k]=C[j], j++ 15 k++ 16 // At this poit all elemets of oe array should be copied to D 17 Copy all elemets of the other array ito D 18 retur D 4.3 Example As a example, cosider the followig array: Mergesort will divide the array ito two subarrays ad The it will recursively sort these two arrays ad give back ad To merge these two arrays, we first compare 1 with -2. Because -2 is smaller, it is copied to the fial sorted array. The 1 is compared with 0 ad 0 is copied to the fial array. The 1 ad 2. This time 1 is smaller so 1 is copied to the fial array. Next 5 is compared with 2 ad 2 is copied to fial array. Now the secod array has bee used up so 5 ad 7 of the first array are copied to the fial array. The fial array is

4 4.4 Performace For mergesort, the worst-case ad average-case performaces are the same as the algorithm does ot ivolve ay radom selectio or subarrays of variable legth. Lie 3 ad 4 of the pseudocode each takes T (/2) time ad the Mergeprocedure takes O( B + C ) time, where B ad C are the sizes of the array B ad C. The recurrece relatio is thus T () = 2T (/2) + O(). The computatio tree is like: O() /2 /2 O(2(/2)) O(2 k (/2 k )) log 2 levels We have T () = O(log 2 ). 4.5 Compariso to QuickSort QuickSort is i-place, thus cosumig less space. O the other had, QuickSort is less parallelizable, ad ca potetially suffer from greater time complexity. Both algorithms are widely used, ad i fact, they are both expected to achieve the best ruig time that a compariso-based sortig algorithm ca hope for, which is O(log). 5 Multiplyig Bit Strigs The problem is to multiply two -bit umbers x ad y. The straightforward way is to divide each umber ito two parts ad each part has 2 bit. x y x L y L x R y R /2 /2 We have x = x L xr y = y L yr xy = x L y L 2 + (x L y R + y L x R )2 2 + xr y R The ruig time T () = 4T ( 2 ) + O(). This recurrece relatio ca be solved by computatio tree. 2-4

5 O() /2 /2 /2 /2 O(2 1 ) O(2 k ) log 2 levels We have T () = ( k log 2 ) = (2 log ) = O( 2 ) There is a smarter way to do the multiplicatio based o the fact that xy = x L y L 2 + (x L y R + y L x R )2 2 + xr y R = x L y L 2 + ((x L + x R )(y L + y R ) x R y R x L y L ) + x R y R Oly three multiplicatios are eeded: x L y L, x R y R ad (x L + x R )(y L + y R ). We have T () = 3T ( 2 ) + O() The computatio tree is like O() /2 /2 /2 O((3/2)) O(3/2) k ) log 2 levels We have T () = ( (3 2 )2 +...( 3 2 )k ( 3 2 )log 2 ) = O(( 3 2 )log 2 ) = O(3 log 2 ) = O( log 2 3 ) O( ) 6 Polyomial Multiplicatio Polyomial Multiplicatio is aother example where Divide-ad-Coquer techique ca be applied. Assume ad P(x) = Q(x) = k=0 k=0 a k x k b k x k. 2-5

6 If we aively multiply them term by term, it would be of complexity O( 2 ). However, we ca apply the followig trick. Write ad The P(x) = Q(x) = 2 i=0 2 i=0 a i x i + x 2 b i x i + x 2 2 i=0 a i+/2 x i = P 1 (x) + x 2 P2 (x) 2 b i+/2 x i = Q 1 (x) + x 2 Q2 (x). i=0 PQ = P 1 Q 1 + x 2 (P1 Q 2 + P 2 Q 1 ) + x P 2 Q 2. (1) The above equatio tells us that we ca divide the problem ito 4 subproblems with half of the origial iput size, which gives us the followig recurrece relatio: T () = 4T ( 2 ) + O() However, we ca improve this to T () = 3T ( 2 ) + O() by the fact that P 1 Q 2 + P 2 Q 1 = (P 1 + P 2 )(Q 1 + Q 2 ) P 1 Q 1 P 2 Q 2. (2) Note that P 1 Q 1 ad P 2 Q 2 i equatio 2 also appear i equatio 1. Therefore we oly eed to compute oe more multiplicatio, which is (P 1 + P 2 )(Q 1 + Q 2 ), givig us the followig recurrece relatio T () = 3T ( 2 ) + O() This recurrece relatio gives us T () = O( log 2 3 ), which is faster tha aively multiplyig out all terms. 7 Media Fidig ad Selectio Suppose we are give a elemet array A ad we wish to fid its media. A immediate algorithm to this problem would be to first sort A usig your favorite O(log)-time sortig algorithm. The, we ca look at (/2)th elemet i this sorted array to fid the media. However, this approach seems to beig too much work the added time it takes to order all the elemets is uecessary sice we re oly iterested i fidig the media. Ideally, we could fid the media i O() time (a algorithm that solves this problem must ru i Ω() time; ca you argue why?) Istead of fidig the media of A, we will actually solve the problem of selectio istead, which is a slightly more geeral problem. Specifically, the algorithm is ow give a parameter k as iput ad is asked to fid the kth smallest item i A (i.e., the elemet we would fid at idex k if A was sorted). Clearly, solvig selectio solves the problem of media fidig if we set k = /2. This more geeral structure will allow us to correctly defie our coquer step whe devisig our divide-ad-coquer algorithm. 2-6

7 7.1 A DAC Algorithm for Selectio Our goal is to defie a algorithm that fids the kth smallest elemet of a elemet A i O() time. We begi by defiig the followig correct (but as we will see) iefficiet algorithm SELECTION(A,k): 1. Select a pivot value p A (for ow, we do this arbitrarily). The, restructure A so that it is the cocateatio of the followig three subarrays: all elemets less tha p, followed by elemets equal to p, ad the followed by elemets greater tha p; call these regios A 1, A 2, ad A 3, respectively. We will also deote that A i = i. 2. If k 1, we retur SELECTION(A 1,k). Sice A 1 cotais the 1 smallest elemets i A ad k 1, we kow that the kth smallest elemet i A 1 is also the kth smallest elemet i A. Thus makig a recursive call o A 1 that leaves the value of k uchaged will correctly retur the desired elemet. 3. If 1 < k 1 + 2, simply retur p. Here we kow that the kth smallest elemet lies i A 2. Sice this subarray oly cotais the value p, the desired etry must be the pivot p. 4. Otherwise, k > 1 + 2, i which case we retur SELECTION(A 3,k 1 2 ). Now we kow our desired elemet is i subarray A 3 ; however, because this array is preceded by A 1 ad A 2, we ow must locate the (k 1 2 )th smallest elemet i A 3 if we wat to fid the kth smallest elemet i the overall array A (this just accouts for the precedig elemets that we are essetially choppig-off whe we make a recursive call that oly examies A 3 ). This completes the algorithm s defiitio (ote that here, step 1 defies the divide step, ad steps 2-4 defie our coquer step; there is o combie procedure i this case). It should ow be clear that this algorithm is ideed correct; however, if we are ot careful as to how we pick our pivot p, the ruig time of the algorithm will suffer i the same way we saw quick-sort suffer i the last lecture. More specifically, let T () be the ruig-time of the algorithm o a elemet array. Recall that step 1 (i.e., pickig a pivot ad restructurig the array) ca be doe i O() time. The ruig time of steps 2-4 will deped o what case we fall i, but regardless, we ca say it is bouded by T (max{ 1, 3 }) sice we oly ever make recursive calls o A 1 or A 3 (but ot both). If we get a eve split each time we make a recursive call ad 1 3 /2, we will be i good shape. Formally, the ruig time of the algorithm i this case is give by: T () = T (/2) + O() c ( + /2 + / ) (3) = c (1 + 1/2 + 1/ /) (4) < c 2 = O(), (5) where c is the costat hidde by the O() term i the origial recurrece. It should be fairly straightforward to see why if we expad the recurrece, we obtai lie (3). To see why iequality (5) is true, we quickly review geometric series. Recall (hopefully) that for some real umber 0 r < 1, we have that 1 + r + r 2 + r = i=0 r i = 1 1 r. (6) For lie (4), we have that r = 1/2 whe examiig the term (1 + 1/2 + 1/ /). Sice this sum is bouded by i=0 (1/2)i (the latter is a ifiite sum whose terms subsumes the fiite series i the former), 2-7

8 the closed form for a ifiite geometric series give by (6) implies that these terms are bouded by 1/(1 1/2) = 2. Turig our attetio back to SELECTION, the case where A 1 ad A 3 are roughly equal i size will result i this ideal ruig time; however, sice we curretly have o rule for pickig a pivot, there is othig prevetig, say, 1 = 0 ad 3 = 1. If this worst case occurs for every recursive call we make, the ruig time is ow: T () = T ( 1) + O() = c ( ) = O( 2 ). Thus, as curretly defied, the ruig time of SELECTION(A,k) is O( 2 ), which is worse tha the O(log) aive sortig approach we first gave. Clearly, if we wat to get ay pay dirt out of this algorithm, we will have to fid a way of pickig the pivot so that we maitai at least some balace betwee the sizes of A 1 ad A Pickig a Good Pivot As outlied above, we would ideally like to pick a pivot so that 1 3 /2. The best pivot to pick the is just the media of A; however, this is a bit circular. Selectio is a problem that, at least whe k = /2, is tryig to fid the media i the first place! Therefore, the somewhat arcae pivot-fidig procedure we are about to defie attempts to fid a approximate media i O() time. If there is at least some balace betwee A 1 ad A 3, hopefully we ca discard a large eough fractio of the array i each recursive call to yield our desired O() rutime. Our ew pivot procedure, which we will call PIVOT-FIND(A), is defied as follows (where agai A = ): 1. Divide A ito /5 blocks B 1,...,B /5 each of size 5 (assume for sake simplicity that is divisible by 5). 2. Sort each of these blocks idividually, ad so afterwards, the 5 elemets i a give block B i are sorted with respect to oe aother. Note that the media of each block is ow the third elemet withi that block. 3. For each block B i, store B i s media i a ew array C of size /5. 4. We the retur our pivot to be SELECTION(C,/10), which is the media of C (/10 comes from the fact there are /5 elemets i C, ad therefore the midway poit i this array will be at /10). The most iterestig observatio to make about this procedure is the fact we are usig a recursive call to SELECTION as our meas of pickig the pivot. Thus, we are couterituitively usig the very dividead-coquer algorithm we are attemptig to defie as a subroutie whe defiig our divide step (pickig a pivot). So for example, cosider our first recursive call to SELECTION(A,k). By the time PIVOT-FIND(A) completes, we will have made several cascadig calls to SELECTION ad PIVOT-FIND o smaller arrays before eve reachig the first recursive coquer steps i our top recursive call (steps 2-4 i SELECTION). By o meas is this a typical approach whe defiig divide-ad-coquer algorithms, but it is a great example of how oe ca take a algorithmic paradigm ad creatively dovetail stadard techiques i order to costruct a faster algorithm. 2-8

9 Also ote that this procedure ideed rus i O() time. Step 1-2 will take O() time sice there are /5 blocks, each of which take O(1) time to sort sice they each have a costat umber of elemets (eve if we use bubble-sort or isertio-sort). Steps 3-4 will take O() time, as well, sice we ca step through all the blocks i /5 steps, pluck out each media at a give block s third locatio, ad the add it to C; hece, the procedure s overall ruig time is i O(). Now, let s see what this ew PIVOT-FIND(A) buys us. To do our aalysis, cosider reorderig the blocks so that they are sorted by their medias. More formally, we specify this orderig as B φ(1), B φ(2),...,b φ(/5), where φ is a fuctio that remaps the block idices such that if m i is the media of block B i, we have that m φ(i) m φ( j) for all j < i ad m φ(i) m φ( j) for all j > i. It is importat to ote that the algorithm is ot actually performig this reorderig we are just defiig this structure for sake of aalysis. Observe that the pivot p retured by SELECTION(C,/10) is the media of block B φ(/10). Now, defie the followig sets: Let S 1 be the set of all x A such that x B φ( j), x m φ( j), ad j /10 (recall that we defied m i to be the media of block B i ). Iformally, these are elemets that exist i the first half of this block orderig ad are less or equal to the media of the block to which they belog. Similarly, let S 2 be the set of y A such that y B φ( j), y m φ( j), ad j /10. Likewise, this is the set of elemets that exist i the secod half of our block orderig ad are o smaller tha the medias of their respective blocks. Figure 1 illustrates the defiitios of these sets. So what is all this structure good for? Remember our goal is to make sure that both A 1 ad A 3 receive a large eough fractio of the elemets. The followig lemma makes use of our block orderig B φ(1),...,b φ(/5) ad our ewly defied sets S 1 ad S 2 to argue that if we use PIVOT-FIND to fid our pivot, we ideed obtai some balace. Lemma 1. If we use PIVOT-FIND to pick the pivot p, the max{ 1, 3 } 7/10. Proof. Our key observatios are that S 1 A 1 A 2 ad S 2 A 2 A 3. Here, we will argue that the former claim is true ad show it implies that 3 7/10. We will leave establishig S 2 A 2 A 3 ad showig that this implies 1 7/10 as a exercise (although, it should be symmetric to the argumet we preset here). Let x S 1. Therefore, x exists i some block B φ( j) where j /10 ad is less tha or equal to the media of its block m φ( j). Sice j /10, m φ( j) must lie i the first half of C ad therefore is o greater tha the media of C. Sice PIVOT-FIND esures that p is the media of C, we have that m φ( j) p. Thus, it follows that x p, implyig that x A 1 A 2, as desired. To complete the proof, observe that S 1 cotais 3/5 of the elemets i blocks B φ(1),...,b φ(/10), sice for each of these blocks, S 1 icludes the media ad the two precedig elemets. Sice these blocks accout for half the elemets i etire array A, it follows S 1 = 3/10. However, we just showed S 1 is a subset of A 1 A 2, implyig that A 1 A 2 caot be smaller tha 3/10. This implies that A 3 = 3 ca be o larger tha 7/10 sice =. As metioed at the start of the proof, a symmetric argumet ca be made to show 1 7/10. Hece, we have that max{ 1, 3 } 7/10. We are ow ready to complete our ru-time aalysis for SELECTION with PIVOT-FIND. Let s briefly recall the ruig times of all the compoets i a give recursive call of SELECTION(A, k), where agai we deote T () to be the total ruig time of this call if A =. 2-9

10 B (1) B (2). B (5). B (9) S 1 C S Figure 1: A diagram illustratig the defiitios of B φ(1),...,b φ(/5), C, S 1, ad S 2. Here = 45, ad thus we have 9 blocks i total. Observe that each block is sorted idividually ad that the blocks themselves are ordered based o their medias. Array C is outlied i red, ad the media of C, circled i pik, would serve as our pivot p. Sets S 1 ad S 2 are highlighted by the blue ad gree boxes, respectively. Also observe that all the elemets i S 1 ad S 2 are less tha ad greater tha the pivot, respectively (which is argued formally i Lemma 1). 2-10

11 Steps 1-3 of PIVOT-FIND, where we divide our array ito blocks ad create the array of medias C, takes O() time. Step 4 of PIVOT-FIND makes a call to SELECTION(C,/10); sice C is a array of size /5, this will take T (/5) time. Restructurig the array aroud the pivot i steps 1-2 of SELECTION takes O() time. As we argued earlier, steps 2-4 of SELECTION take T (max{ 1, 3 }) time. By Lemma 1, we kow that this will be at most T (7/10). Thus, the overall ruig time of the algorithm is as follows (we will agai use c as the costat that is hidde by the O() term that bouds the ruig times of creatig array C ad pivotig the array aroud p). T () = T (7/10) + T (/5) + c ( ) 9 i < c (7) 10 i=0 = c 10 = O(), (8) as desired. You should try to verify iequality (7) (use the tree expasio method; you should get that the total work doe o the kth level of the tree is c (9/10) k ). Equatio (8) follows by the closed form for a geometric series we saw earlier i equatio (6). A fial ote: observe that if we had picked the size of each block to be 4 istead of 5, the recurrece would ow become T () = T (3/4) + T (/4) + O(). Whe we expad the recursio tree for this recurrece, we are doig c work at each level of the tree. Sice the tree will have O(log) levels, we istead get a ruig time of O(log). Thus, the decisio to use blocks of 5 was carefully made whe desigig the algorithm to avoid gettig this extra O(log) factor. Pickig aythig greater tha 5 will also work, but we will still get a O() time algorithm sice doig this will oly improve the costat we get o lie (8) (ad remember, ay algorithm for selectio must take Ω() time). 8 Master Theorem Let us aalyze a recurrece relatio for a geeral divide-ad-coquer algorithm: T () = at ( b ) + O(d ). The computatio tree is like: O( d ) a braches /b O(a(/b) d ) O(a k (/b k ) d ) log b levels 2-11

12 We have T () = O( d +a( b )d +...+a k ( ) d +...+a log b k b ( ) d ), where the item a log b log b b ( ) d = a log b log b b = log b a. The solutio is based o the compariso betwee d ad log b a. There are three situatios: d > log b a: T () = log b 1 j=0 a j ( ) d = d a b j b d log b a 1 a d < log b a: T () = log b 1 j=0 a j ( ) d = d a b j O( log b a ). b d. The item d domiates ad we have T () = O( d ). b d log b a 1 a b d. The item log b a domiates ad we have T () = d = log b a: All items have the same power ad we have T () = O( log b 1 j=0 a j b d j d ) = O( d log b ). 2-12

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Divide 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 information

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)

CS 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 information

Analysis of Algorithms. Introduction. Contents

Analysis of Algorithms. Introduction. Contents Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We

More information

CS / MCS 401 Homework 3 grader solutions

CS / 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 information

4.3 Growth Rates of Solutions to Recurrences

4.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 information

Design and Analysis of Algorithms

Design 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 information

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.

Divide & 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 information

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Sorting 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 information

Analysis of Algorithms -Quicksort-

Analysis 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 information

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

CS 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 information

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES

OPTIMAL 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 information

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

This 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 information

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Classification 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 information

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018 CSE 353 Discrete Computatioal Structures Sprig 08 Sequeces, Mathematical Iductio, ad Recursio (Chapter 5, Epp) Note: some course slides adopted from publisher-provided material Overview May mathematical

More information

Infinite Sequences and Series

Infinite Sequences and Series Chapter 6 Ifiite Sequeces ad Series 6.1 Ifiite Sequeces 6.1.1 Elemetary Cocepts Simply speakig, a sequece is a ordered list of umbers writte: {a 1, a 2, a 3,...a, a +1,...} where the elemets a i represet

More information

An Introduction to Randomized Algorithms

An Introduction to Randomized Algorithms A Itroductio to Radomized Algorithms The focus of this lecture is to study a radomized algorithm for quick sort, aalyze it usig probabilistic recurrece relatios, ad also provide more geeral tools for aalysis

More information

Average-Case Analysis of QuickSort

Average-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 information

CS 332: Algorithms. Quicksort

CS 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 information

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability.

CSE 202 Homework 1 Matthias Springer, A Yes, there does always exist a perfect matching without a strong instability. CSE 0 Homework 1 Matthias Spriger, A9950078 1 Problem 1 Notatio a b meas that a is matched to b. a < b c meas that b likes c more tha a. Equality idicates a tie. Strog istability Yes, there does always

More information

CHAPTER I: Vector Spaces

CHAPTER I: Vector Spaces CHAPTER I: Vector Spaces Sectio 1: Itroductio ad Examples This first chapter is largely a review of topics you probably saw i your liear algebra course. So why cover it? (1) Not everyoe remembers everythig

More information

Math 155 (Lecture 3)

Math 155 (Lecture 3) Math 55 (Lecture 3) September 8, I this lecture, we ll cosider the aswer to oe of the most basic coutig problems i combiatorics Questio How may ways are there to choose a -elemet subset of the set {,,,

More information

Data Structures Lecture 9

Data 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 information

Recurrence Relations

Recurrence 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 information

P1 Chapter 8 :: Binomial Expansion

P1 Chapter 8 :: Binomial Expansion P Chapter 8 :: Biomial Expasio jfrost@tiffi.kigsto.sch.uk www.drfrostmaths.com @DrFrostMaths Last modified: 6 th August 7 Use of DrFrostMaths for practice Register for free at: www.drfrostmaths.com/homework

More information

6.3 Testing Series With Positive Terms

6.3 Testing Series With Positive Terms 6.3. TESTING SERIES WITH POSITIVE TERMS 307 6.3 Testig Series With Positive Terms 6.3. Review of what is kow up to ow I theory, testig a series a i for covergece amouts to fidig the i= sequece of partial

More information

Algorithms and Data Structures Lecture IV

Algorithms 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 information

Lecture 2: April 3, 2013

Lecture 2: April 3, 2013 TTIC/CMSC 350 Mathematical Toolkit Sprig 203 Madhur Tulsiai Lecture 2: April 3, 203 Scribe: Shubhedu Trivedi Coi tosses cotiued We retur to the coi tossig example from the last lecture agai: Example. Give,

More information

Skip 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

Skip 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 information

Lecture 11: Pseudorandom functions

Lecture 11: Pseudorandom functions COM S 6830 Cryptography Oct 1, 2009 Istructor: Rafael Pass 1 Recap Lecture 11: Pseudoradom fuctios Scribe: Stefao Ermo Defiitio 1 (Ge, Ec, Dec) is a sigle message secure ecryptio scheme if for all uppt

More information

Model of Computation and Runtime Analysis

Model 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 information

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3

(A sequence also can be thought of as the list of function values attained for a function f :ℵ X, where f (n) = x n for n 1.) x 1 x N +k x N +4 x 3 MATH 337 Sequeces Dr. Neal, WKU Let X be a metric space with distace fuctio d. We shall defie the geeral cocept of sequece ad limit i a metric space, the apply the results i particular to some special

More information

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions

CSE 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 information

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ. 2 5. Weighted umber of late jobs 5.1. Release dates ad due dates: maximimizig the weight of o-time jobs Oce we add release dates, miimizig the umber of late jobs becomes a sigificatly harder problem. For

More information

Test One (Answer Key)

Test 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 information

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Recursive 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 information

The Binomial Theorem

The Binomial Theorem The Biomial Theorem Robert Marti Itroductio The Biomial Theorem is used to expad biomials, that is, brackets cosistig of two distict terms The formula for the Biomial Theorem is as follows: (a + b ( k

More information

Fundamental Algorithms

Fundamental 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 information

A Probabilistic Analysis of Quicksort

A Probabilistic Analysis of Quicksort A Probabilistic Aalysis of Quicsort You are assumed to be familiar with Quicsort. I each iteratio this sortig algorithm chooses a pivot ad the, by performig comparisios with the pivot, splits the remaider

More information

Math 104: Homework 2 solutions

Math 104: Homework 2 solutions Math 04: Homework solutios. A (0, ): Sice this is a ope iterval, the miimum is udefied, ad sice the set is ot bouded above, the maximum is also udefied. if A 0 ad sup A. B { m + : m, N}: This set does

More information

Model of Computation and Runtime Analysis

Model 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 information

1 Hash tables. 1.1 Implementation

1 Hash tables. 1.1 Implementation Lecture 8 Hash Tables, Uiversal Hash Fuctios, Balls ad Bis Scribes: Luke Johsto, Moses Charikar, G. Valiat Date: Oct 18, 2017 Adapted From Virgiia Williams lecture otes 1 Hash tables A hash table is a

More information

COMP285 Midterm Exam Department of Mathematics

COMP285 Midterm Exam Department of Mathematics COMP85 Midterm Exam Departmet of Mathematics Fall 010/011 - November 8, 010 Name: Studet Number: Please fiish withi 90 miutes. All poits above 100 are cosidered as bous poit. You ca reach maximal 1 poits.

More information

CHAPTER 10 INFINITE SEQUENCES AND SERIES

CHAPTER 10 INFINITE SEQUENCES AND SERIES CHAPTER 10 INFINITE SEQUENCES AND SERIES 10.1 Sequeces 10.2 Ifiite Series 10.3 The Itegral Tests 10.4 Compariso Tests 10.5 The Ratio ad Root Tests 10.6 Alteratig Series: Absolute ad Coditioal Covergece

More information

x a x a Lecture 2 Series (See Chapter 1 in Boas)

x a x a Lecture 2 Series (See Chapter 1 in Boas) Lecture Series (See Chapter i Boas) A basic ad very powerful (if pedestria, recall we are lazy AD smart) way to solve ay differetial (or itegral) equatio is via a series expasio of the correspodig solutio

More information

Merge and Quick Sort

Merge 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 information

Seunghee Ye Ma 8: Week 5 Oct 28

Seunghee Ye Ma 8: Week 5 Oct 28 Week 5 Summary I Sectio, we go over the Mea Value Theorem ad its applicatios. I Sectio 2, we will recap what we have covered so far this term. Topics Page Mea Value Theorem. Applicatios of the Mea Value

More information

MA131 - Analysis 1. Workbook 2 Sequences I

MA131 - Analysis 1. Workbook 2 Sequences I MA3 - Aalysis Workbook 2 Sequeces I Autum 203 Cotets 2 Sequeces I 2. Itroductio.............................. 2.2 Icreasig ad Decreasig Sequeces................ 2 2.3 Bouded Sequeces..........................

More information

Sequences. Notation. Convergence of a Sequence

Sequences. Notation. Convergence of a Sequence Sequeces A sequece is essetially just a list. Defiitio (Sequece of Real Numbers). A sequece of real umbers is a fuctio Z (, ) R for some real umber. Do t let the descriptio of the domai cofuse you; it

More information

) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È

) 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 information

Math 475, Problem Set #12: Answers

Math 475, Problem Set #12: Answers Math 475, Problem Set #12: Aswers A. Chapter 8, problem 12, parts (b) ad (d). (b) S # (, 2) = 2 2, sice, from amog the 2 ways of puttig elemets ito 2 distiguishable boxes, exactly 2 of them result i oe

More information

1 Approximating Integrals using Taylor Polynomials

1 Approximating Integrals using Taylor Polynomials Seughee Ye Ma 8: Week 7 Nov Week 7 Summary This week, we will lear how we ca approximate itegrals usig Taylor series ad umerical methods. Topics Page Approximatig Itegrals usig Taylor Polyomials. Defiitios................................................

More information

TEACHER CERTIFICATION STUDY GUIDE

TEACHER CERTIFICATION STUDY GUIDE COMPETENCY 1. ALGEBRA SKILL 1.1 1.1a. ALGEBRAIC STRUCTURES Kow why the real ad complex umbers are each a field, ad that particular rigs are ot fields (e.g., itegers, polyomial rigs, matrix rigs) Algebra

More information

Problem Set 2 Solutions

Problem Set 2 Solutions CS271 Radomess & Computatio, Sprig 2018 Problem Set 2 Solutios Poit totals are i the margi; the maximum total umber of poits was 52. 1. Probabilistic method for domiatig sets 6pts Pick a radom subset S

More information

Lecture 2. The Lovász Local Lemma

Lecture 2. The Lovász Local Lemma Staford Uiversity Sprig 208 Math 233A: No-costructive methods i combiatorics Istructor: Ja Vodrák Lecture date: Jauary 0, 208 Origial scribe: Apoorva Khare Lecture 2. The Lovász Local Lemma 2. Itroductio

More information

CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)

CSI 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 information

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

A 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 information

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:

Department 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 information

Math 113 Exam 3 Practice

Math 113 Exam 3 Practice Math Exam Practice Exam will cover.-.9. This sheet has three sectios. The first sectio will remid you about techiques ad formulas that you should kow. The secod gives a umber of practice questios for you

More information

On Random Line Segments in the Unit Square

On Random Line Segments in the Unit Square O Radom Lie Segmets i the Uit Square Thomas A. Courtade Departmet of Electrical Egieerig Uiversity of Califoria Los Ageles, Califoria 90095 Email: tacourta@ee.ucla.edu I. INTRODUCTION Let Q = [0, 1] [0,

More information

SNAP Centre Workshop. Basic Algebraic Manipulation

SNAP Centre Workshop. Basic Algebraic Manipulation SNAP Cetre Workshop Basic Algebraic Maipulatio 8 Simplifyig Algebraic Expressios Whe a expressio is writte i the most compact maer possible, it is cosidered to be simplified. Not Simplified: x(x + 4x)

More information

Ma 530 Introduction to Power Series

Ma 530 Introduction to Power Series Ma 530 Itroductio to Power Series Please ote that there is material o power series at Visual Calculus. Some of this material was used as part of the presetatio of the topics that follow. What is a Power

More information

1 Generating functions for balls in boxes

1 Generating functions for balls in boxes Math 566 Fall 05 Some otes o geeratig fuctios Give a sequece a 0, a, a,..., a,..., a geeratig fuctio some way of represetig the sequece as a fuctio. There are may ways to do this, with the most commo ways

More information

Examples: data compression, path-finding, game-playing, scheduling, bin packing

Examples: 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 information

Sequences I. Chapter Introduction

Sequences I. Chapter Introduction Chapter 2 Sequeces I 2. Itroductio A sequece is a list of umbers i a defiite order so that we kow which umber is i the first place, which umber is i the secod place ad, for ay atural umber, we kow which

More information

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer.

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer. 6 Itegers Modulo I Example 2.3(e), we have defied the cogruece of two itegers a,b with respect to a modulus. Let us recall that a b (mod ) meas a b. We have proved that cogruece is a equivalece relatio

More information

The Growth of Functions. Theoretical Supplement

The Growth of Functions. Theoretical Supplement The Growth of Fuctios Theoretical Supplemet The Triagle Iequality The triagle iequality is a algebraic tool that is ofte useful i maipulatig absolute values of fuctios. The triagle iequality says that

More information

MA131 - Analysis 1. Workbook 3 Sequences II

MA131 - Analysis 1. Workbook 3 Sequences II MA3 - Aalysis Workbook 3 Sequeces II Autum 2004 Cotets 2.8 Coverget Sequeces........................ 2.9 Algebra of Limits......................... 2 2.0 Further Useful Results........................

More information

INTEGRATION BY PARTS (TABLE METHOD)

INTEGRATION BY PARTS (TABLE METHOD) INTEGRATION BY PARTS (TABLE METHOD) Suppose you wat to evaluate cos d usig itegratio by parts. Usig the u dv otatio, we get So, u dv d cos du d v si cos d si si d or si si d We see that it is ecessary

More information

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary

Recursive 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 information

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

CSI 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 information

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

CS583 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 information

CS 5150/6150: Assignment 1 Due: Sep 23, 2010

CS 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 information

Lecture 9: Hierarchy Theorems

Lecture 9: Hierarchy Theorems IAS/PCMI Summer Sessio 2000 Clay Mathematics Udergraduate Program Basic Course o Computatioal Complexity Lecture 9: Hierarchy Theorems David Mix Barrigto ad Alexis Maciel July 27, 2000 Most of this lecture

More information

Lecture 1: Basic problems of coding theory

Lecture 1: Basic problems of coding theory Lecture 1: Basic problems of codig theory Error-Correctig Codes (Sprig 016) Rutgers Uiversity Swastik Kopparty Scribes: Abhishek Bhrushudi & Aditya Potukuchi Admiistrivia was discussed at the begiig of

More information

Chapter 3. Strong convergence. 3.1 Definition of almost sure convergence

Chapter 3. Strong convergence. 3.1 Definition of almost sure convergence Chapter 3 Strog covergece As poited out i the Chapter 2, there are multiple ways to defie the otio of covergece of a sequece of radom variables. That chapter defied covergece i probability, covergece i

More information

4.1 Sigma Notation and Riemann Sums

4.1 Sigma Notation and Riemann Sums 0 the itegral. Sigma Notatio ad Riema Sums Oe strategy for calculatig the area of a regio is to cut the regio ito simple shapes, calculate the area of each simple shape, ad the add these smaller areas

More information

Statistics 511 Additional Materials

Statistics 511 Additional Materials Cofidece Itervals o mu Statistics 511 Additioal Materials This topic officially moves us from probability to statistics. We begi to discuss makig ifereces about the populatio. Oe way to differetiate probability

More information

Complex Numbers Solutions

Complex Numbers Solutions Complex Numbers Solutios Joseph Zoller February 7, 06 Solutios. (009 AIME I Problem ) There is a complex umber with imagiary part 64 ad a positive iteger such that Fid. [Solutio: 697] 4i + + 4i. 4i 4i

More information

7. Modern Techniques. Data Encryption Standard (DES)

7. Modern Techniques. Data Encryption Standard (DES) 7. Moder Techiques. Data Ecryptio Stadard (DES) The objective of this chapter is to illustrate the priciples of moder covetioal ecryptio. For this purpose, we focus o the most widely used covetioal ecryptio

More information

Regression with quadratic loss

Regression with quadratic loss Regressio with quadratic loss Maxim Ragisky October 13, 2015 Regressio with quadratic loss is aother basic problem studied i statistical learig theory. We have a radom couple Z = X,Y, where, as before,

More information

Introduction to Computational Molecular Biology. Gibbs Sampling

Introduction to Computational Molecular Biology. Gibbs Sampling 18.417 Itroductio to Computatioal Molecular Biology Lecture 19: November 16, 2004 Scribe: Tushara C. Karuarata Lecturer: Ross Lippert Editor: Tushara C. Karuarata Gibbs Samplig Itroductio Let s first recall

More information

Math 113, Calculus II Winter 2007 Final Exam Solutions

Math 113, Calculus II Winter 2007 Final Exam Solutions Math, Calculus II Witer 7 Fial Exam Solutios (5 poits) Use the limit defiitio of the defiite itegral ad the sum formulas to compute x x + dx The check your aswer usig the Evaluatio Theorem Solutio: I this

More information

CS161 Design and Analysis of Algorithms. Administrative

CS161 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 information

Lecture 3: Asymptotic Analysis + Recurrences

Lecture 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 information

Disjoint set (Union-Find)

Disjoint 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 information

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) =

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) = AN INTRODUCTION TO SCHRÖDER AND UNKNOWN NUMBERS NICK DUFRESNE Abstract. I this article we will itroduce two types of lattice paths, Schröder paths ad Ukow paths. We will examie differet properties of each,

More information

Machine Learning Theory Tübingen University, WS 2016/2017 Lecture 12

Machine Learning Theory Tübingen University, WS 2016/2017 Lecture 12 Machie Learig Theory Tübige Uiversity, WS 06/07 Lecture Tolstikhi Ilya Abstract I this lecture we derive risk bouds for kerel methods. We will start by showig that Soft Margi kerel SVM correspods to miimizig

More information

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES Read Sectio 1.5 (pages 5 9) Overview I Sectio 1.5 we lear to work with summatio otatio ad formulas. We will also itroduce a brief overview of sequeces,

More information

REGRESSION WITH QUADRATIC LOSS

REGRESSION WITH QUADRATIC LOSS REGRESSION WITH QUADRATIC LOSS MAXIM RAGINSKY Regressio with quadratic loss is aother basic problem studied i statistical learig theory. We have a radom couple Z = X, Y ), where, as before, X is a R d

More information

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 22

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 22 CS 70 Discrete Mathematics for CS Sprig 2007 Luca Trevisa Lecture 22 Aother Importat Distributio The Geometric Distributio Questio: A biased coi with Heads probability p is tossed repeatedly util the first

More information

Math 2784 (or 2794W) University of Connecticut

Math 2784 (or 2794W) University of Connecticut ORDERS OF GROWTH PAT SMITH Math 2784 (or 2794W) Uiversity of Coecticut Date: Mar. 2, 22. ORDERS OF GROWTH. Itroductio Gaiig a ituitive feel for the relative growth of fuctios is importat if you really

More information

The Structure of Z p when p is Prime

The Structure of Z p when p is Prime LECTURE 13 The Structure of Z p whe p is Prime Theorem 131 If p > 1 is a iteger, the the followig properties are equivalet (1) p is prime (2) For ay [0] p i Z p, the equatio X = [1] p has a solutio i Z

More information

PROBLEM SET 5 SOLUTIONS 126 = , 37 = , 15 = , 7 = 7 1.

PROBLEM SET 5 SOLUTIONS 126 = , 37 = , 15 = , 7 = 7 1. Math 7 Sprig 06 PROBLEM SET 5 SOLUTIONS Notatios. Give a real umber x, we will defie sequeces (a k ), (x k ), (p k ), (q k ) as i lecture.. (a) (5 pts) Fid the simple cotiued fractio represetatios of 6

More information

Lecture 27. Capacity of additive Gaussian noise channel and the sphere packing bound

Lecture 27. Capacity of additive Gaussian noise channel and the sphere packing bound Lecture 7 Ageda for the lecture Gaussia chael with average power costraits Capacity of additive Gaussia oise chael ad the sphere packig boud 7. Additive Gaussia oise chael Up to this poit, we have bee

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desig ad Aalysis of Algorithms Probabilistic aalysis ad Radomized algorithms Referece: CLRS Chapter 5 Topics: Hirig problem Idicatio radom variables Radomized algorithms Huo Hogwei 1 The hirig problem

More information

CS 171 Lecture Outline October 09, 2008

CS 171 Lecture Outline October 09, 2008 CS 171 Lecture Outlie October 09, 2008 The followig theorem comes very hady whe calculatig the expectatio of a radom variable that takes o o-egative iteger values. Theorem: Let Y be a radom variable that

More information

Convergence of random variables. (telegram style notes) P.J.C. Spreij

Convergence of random variables. (telegram style notes) P.J.C. Spreij Covergece of radom variables (telegram style otes).j.c. Spreij this versio: September 6, 2005 Itroductio As we kow, radom variables are by defiitio measurable fuctios o some uderlyig measurable space

More information

Lecture 9: Pseudo-random generators against space bounded computation,

Lecture 9: Pseudo-random generators against space bounded computation, Lecture 9: Pseudo-radom geerators agaist space bouded computatio, Primality Testig Topics i Pseudoradomess ad Complexity (Sprig 2018) Rutgers Uiversity Swastik Kopparty Scribes: Harsha Tirumala, Jiyu Zhag

More information

Section 1.1. Calculus: Areas And Tangents. Difference Equations to Differential Equations

Section 1.1. Calculus: Areas And Tangents. Difference Equations to Differential Equations Differece Equatios to Differetial Equatios Sectio. Calculus: Areas Ad Tagets The study of calculus begis with questios about chage. What happes to the velocity of a swigig pedulum as its positio chages?

More information

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

Matriculation 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 information