GC05: Algorithmic Complexity & Computability

Size: px
Start display at page:

Download "GC05: Algorithmic Complexity & Computability"

Transcription

1 GC05: Algorithmic Complexity & Computability This part of the course deals with assessig the time-demad of algorithmic procedures with the aim, where possible, of fidig efficiet solutios to problems. We will ot be cosiderig issues related to demads o memory space; for those iterested, these are dealt with for example oe or other of the refereces below. Complexity: Computability: How cheaply ca it be doe? Ca it be doe i ay reasoable time? Ca it be doe at all? Backgroud readig The material i these books is supplemetary to the otes the books are ot essetial for this part of the GC05 course. ALGORITHMICS: The Spirit of Computig - David Harel (Addiso Wesley) A very readable itroductio to the subject, coverig most of the areas dealt with i these lectures ad also may further highly recommeded. INTRODUCTION TO THE DESIGN AND ANALYSIS OF ALGORITHMS - Aay Leviti (Pearso Iteratioal) Clear ad well writte ad about the right level. This course does't follow the book closely but uses a similar style of pseudocode ad some of its examples. ALGORITHMS: Theory ad Practice - Giles Brassard ad Paul Bratley (Pretice-Hall) Detailed mathematical treatmet, goes much further tha this course recommeded if you fid the material iterestig ad wat to lear more. COMPGC05: Part 2.1 1

2 1. INTRODUCTION What is a algorithm? A algorithm is a procedure composed of a sequece of welldefied steps, specified either i a atural laguage (a recipe ca be regarded as a algorithm), or i appropriate code or pseudocode. I these lectures algorithms will be preseted i a simplified pseudocode. A algorithm is able to take a legal iput eg for multiplicatio a pair of umbers is legal, but a pair of text files is ot carry out the specified sequece of steps, ad deliver a output. Algorithms are procedural solutios to problems. Problems to which algorithmic solutios may be sought fall ito four basic classes: Those that admit solutios that ru i reasoable time the class of tractable problems (eg sortig ad searchig). Those that probably do t have reasoable-time algorithmic solutios (eg the Travellig Salesma problem). Those that defiitely do t have such solutios (eg the Towers of Haoi). Those that ca t be solved algorithmically at all the class of o-computable problems (eg the haltig problem). The last three of these will be the subject of Sectio 2 of these lectures. The first part of the course, Sectio 1, will deal with methods for evaluatig the time-complexity of reasoable time algorithms for those tractable problems which do admit such solutios. COMPGC05: Part 2.1 2

3 A tractable problem may however also have a algorithmic solutio which does ot have reasoable time demads. Ofte such a algorithm comes directly from the defiitio of the problem a aïve algorithm but a more subtle approach will yield a more practically useful solutio. Here s a example of a problem which is tractable, but which has also has a aive algorithm that has a very fast growig timedemad that makes this algorithm useless for all but very small iput istaces. Example: evaluatig determiats A determiat is a umber that ca be associated with a square matrix, used for example i the calculatio of the iverse of a matrix. It has a recursive defiitio such that det(m), for a x ( rows ad colums) matrix, is a weighted sum of determiats of (-1)x(-1) sub-matrices. These i tur ca be expressed as the weighted sums of the determiats of (-1) determiats of (-2)x(-2) matrices, ad so o. " det(m) = (!1) j+1 a 1j det(m () [1,j]), >1 j=1 = a 11, =1 (M () [i,j] is the (-1) (-1) matrix formed by deletig the ith row ad jth colum of the matrix M.) This defiitio ca be used as the basis for a simple algorithm, referred to here as the recursive algorithm. Usig it for example for a 3x3 matrix is easy; the calculatio takes oly a few miutes. For a 4x4 or 5x5 it begis to get messy ad time-cosumig... COMPGC05: Part 2.1 3

4 ...but for a 10x10 matrix, forget it. Uless you are exceptioally patiet you would ot wat to do this by had. Ad eve usig a computer it takes a sigificat amout of time. What is't immediately apparet from the 'to calculate the quatity for a istace of size, calculate it for istaces of sizes -1' recursive defiitio is how much work this implies. The recursive algorithm takes a time i the order of!, writte O(!), where! = (-1) (-2) (later i the course we will show this). ('I O(...)' meas 'roughly like (...)' at a ituitive level later we will formalise the defiitio.)! is a extremely fast-growig fuctio, makig it ufeasible to use the recursive algorithm for all but very small matrices ( 5). However there is a alterative algorithm for evaluatig a determiat, based o Gaussia elimiatio, that oly takes time i O( 3 ). The differece betwee the time-demad of the two algorithms as the iput size grows is startlig: size of matrix recursive algorithm Gaussia elimiatio 5 x 5 20 secs 10 x miutes 0.01 secs 20 x 20 >10 millio years 100 x 100!! 5.5 secs COMPGC05: Part 2.1 4

5 Two ways to approach aalysis of algorithms: Empirical: repeatedly ru algorithm with differet iputs get some idea of behaviour o differet sizes of iput ca we be sure we have tested the algorithm o a sufficietly wide rage of iputs? this cosumes the very resource (time) we are tryig to coserve! Theoretical: aalysis of a paper versio of the algorithm ca deal with all cases (eve impractically large iput istaces) machie-idepedet The aim is to obtai some measure of how the time demad of a algorithm grows with the size of its iputs, ad to express the result i a simplified way, usig order otatio, so that the implicatios ca be more easily visualized. Time complexity fuctio Problem size log log x x10 30 > >10 100! 3x10 6 > > > COMPGC05: Part 2.1 5

6 Measurig size of a istace Formally, the size x of a iput istace x is the umber of bits eeded to ecode it, usig some easily-decoded format. e.g. for multiplyig 2 umbers x & y x=2, y=4 x y smaller umber padded with leadig zeros Size of iput = 2 x max ( 1+! " log 2 x# $, 1+! log y # " 2 $ ) [ We will use the fuctios ceilig(x) =! " x # $ floor(x) =! " x # $ = smallest iteger x, = largest iteger x ] But ormally a much more iformal defiitio is used which depeds o the cotext, eg problem sortig calculatig a determiat fidig a miimal spaig tree size of a iput istace umber of items to be sorted umber of rows ad colums i matrix umber of odes i the graph COMPGC05: Part 2.1 6

7 Measurig time take The objective is to make the time-cost aalysis machieidepedet. The differece betwee ruig the same algorithm o two differet machies is oly goig to be some costat factor (eg. this machie is twice as fast as that oe ) which is the same for all iput sizes. The kid of differece that really couts is the sort that itself icreases with size the differece betwee log ad 2, or betwee 3 ad!. A machie-idepedet measure of time is give by coutig elemetary operatios. These are simple operatios used as primitives by all the cadidate algorithms for example whe we say that the cost of a sortig algorithm grows like 2 we will usually be coutig the umber of comparisos doe as a fuctio of, the umber of thigs to be sorted. Other operatios that ca be used as elemetary time-couters are Boolea operatios (AND, OR, etc.), assigmets, ad mathematical operatios such as additio, subtractio, multiplicatio ad divisio. Elemetary operatios are cosidered to themselves be of egligible cost, ad are sometimes for simplicity referred to as beig of uit cost or takig uit time. Note: operatios which are primitive ad cosidered to be of trivial itrisic cost so that they ca be used as time-couters i some cotexts may ot be so lightly dismissed i others. (For example multiplyig 2 umbers ca almost always be thought of as a elemetary operatio, but there are some applicatios, such as cryptology, usig very large umbers (100s or 1000s of decimal digits), where the cost of multiplicatio is ot trivial! The multiplicatio itself eeds to be broke dow ito simpler operatios (sigle-bit oes) ad better algorithms (like Strasse s algorithm) looked for.) COMPGC05: Part 2.1 7

8 Forms of time-complexity aalysis Worst case This is the easiest form of aalysis ad provides a upper boud o the efficiecy of a algorithm (appropriate whe it is ecessary to esure a system will respod fast eough uder all possible circumstaces- eg. cotrollig a uclear power plat) Average case There may be situatios where we are prepared to put up with bad performace o a small proportio of iputs if the average performace is favourable. What does average performace mea? Either sum the times required for every istace of a particular size, divide by the umber of istaces, or evaluate performace with respect to a average istace. (For a sortig algorithm this might well be a radomly ordered file- but what is a average istace for a program processig Eglish-laguage text?) Average case aalysis is mathematically much more difficultmay algorithms exist for which o such aalysis has bee possible. Best case This kid of aalysis differs from the other two i that we cosider ot the algorithm but the problem itself. It should really be referred to as best worst case aalysis, because we aim to arrive at bouds o the performace of all possible algorithmic solutios, assumig their worst cases. Best case aalysis is based o a cosideratio of the logical demads of the problem at had what is the very miimum that ay algorithm to solve this problem would eed to do, i the worst case, for a iput of size? COMPGC05: Part 2.1 8

9 Example: Cosider the multiplicatio of two -bit umbers. Ay algorithm to solve this problem must at least look at each bit of each umber, i the worst case sice otherwise we would be assumig that the product could i geeral be idepedet of some of the 2 bits ad so we ca coclude that multiplicatio is bouded below by a liear fuctio of. Order Notatio The result of a time-complexity aalysis may be some log ad complicated fuctio which describes the way that time-demad grows with iput size. What we really wat to kow is how, roughly, these time-demad fuctios behave like? log? 3? The objective of usig order otatio is to simplify results of complexity aalysis so that the overall shape ad i particular, the behaviour as (asymptotic behaviour) of the timedemad fuctios are more clearly apparet. O-otatio O ca provide a upper boud to time-demad i either worst or average cases. Ituitively, f(x) is O(g(x)) meas that f(x) grows o faster tha g(x) as x gets larger. Formally, The positive-valued fuctio f(x) O(g(x)) if ad oly if there is a value x 0 ad a costat c>0 such that for all x! x 0, f(x) " c.g(x) (Note: the restrictio i the defiitio here for simplicity that f(x) be positive-valued is t likely to cause problems i algorithmic applicatios sice fuctios will represet work doe ad so will always retur positive values i practice.) COMPGC05: Part 2.1 9

10 Useful properties of O 1. O( k.f() ) = O( f() ), for ay costat k This is because multiplicatio by a costat just correspods to a re-adjustmet of the value of the arbitrary costat k i the defiitio of O. This meas that uder O-otatio, we ca forget costat factors (though these hidde costats might be importat i practice, the do t chage the order of the result). Note that as a cosequece of this, sice log a = log a b log b there is o effective differece betwee logarithmic bases uder O-otatio; covetioally we just use O(log ), forgettig the (irrelevat) base. COMPGC05: Part

11 2. O( f() + g() ) = O( max( f(),g() ) ) (for those iterested the proof is o p.56 of Leviti) max here is a shorthad way of sayig the part that grows the fastest as. This result eables us to simplify the result of a complexity aalysis, for example O( + ( )) = O(max(, )) = O( ) 3. O( f() ) U O( g() ) = O( f() + g() ) (ot so easy to prove!) = O( max(f(),g()) ), by 2. above. This last meas that where a algorithm cosists of a sequece of procedures, of differet time-complexities, the overall complexity is just that of the most time-demadig part. Examples of proofs usig O-otatio [Note: You ca assume i all such proofs that >0, as i this course will represet size of a iput.] For example, is it true that (i) 2 3 O( )? (ii) 3 2 O( )? The geeral way to proceed is as follows: Assume the assertio is true. Work from the defiitio of O, ad try to fid suitable values of c ad o If you ca fid ay pair of values (there s o uique pair) the assertio is, i fact, true. If there is some fudametal reaso why o pair c, 0 could be foud, the the origial hypothesis was wrog ad the assertio is false. COMPGC05: Part

12 ( i) Is 2 3 O( )? Assume it is. The 2! c 3 " 0, for all # 0 $ 2 (1! c) " 0, for all # 0 $ c # 1, for all # 0 $ # 1 c, for all # 0 Choosig (for example) c=2, 0 =1 is satisfactory ad so it s TRUE that 2 3 O( ). (ii) Is 3 2 O( )? Agai, assume it is. The 3! c 2 " 0, for all # 0 $ 2 (! c) " 0, for all # 0 $! c " 0, for all # 0 But c has to have a fixed value. There is o way to satisfy c, for all 0 for a fixed c. Hece the origial assumptio was FALSE, ad 3 2 O( ). Notes Whe aswerig the questio Is f() O(g())? it is ot sufficiet to draw a picture showig the curves f() ad g() -- that ca illustrate your argumet, but is t i itself a proof, as the questio is about what happes as, so ca t be resolved by lookig at ay fiite rage of. If you are asked to base a proof o 'the formal defiitio of O-otatio' do't base your argumet o the three properties listed o pp Argue from the defiitio of O-otatio, as above. COMPGC05: Part

13 Hierarchies of complexity Let be the size of a iput istace, i the usual iformal defiitio (eg degree of a polyomial, legth of a file to be sorted or searched, umber of odes i a graph). Complexity O(1) O(log ) O() O( log ) Costat time: all istructios are executed a fixed umber of times, regardless of the size of the iput. Example: takig the head of a list. Logarithmic: program gets oly slightly slower as grows (typically by usig some trasformatio that progressively cuts dow the size of the problem). Example: biary search. Liear: a costat amout of processig is doe o each iput elemet. Example: searchig a uordered list. Typical of divide ad coquer algorithms, where the problem is solved by breakig it up ito smaller subproblems, solvig them idepedetly, the combiig the solutios. Example: quicksort. O( k ) Polyomial: most ofte arises from the presece of k ested loops (examples: isertiosort (k=2); Gaussia elimiatio method for a calculatig a determiat (k=3). O(a ) Expoetial: very fast-growig (assumig a>1), essetially uusable for all but very small istaces. Example: Towers of Haoi (a=2). O (!) Factorial: eve worse! Example: recursive evaluatio of a determiat. Oly algorithms ruig i polyomial time (those which are i O( k ) for some k) are effectively usable; oly problems which admit such algorithms are effectively soluble (tractable). Thus fidig a determiat is soluble i reasoable time because it has a good algorithm ruig i O( 3 ) as well as a uusable O(!) oe, but the Towers of Haoi puzzle is t, because it ca be demostrated that there are o good algorithms possible i this case. (More about such itractable problems later.) COMPGC05: Part

14 2. ANALYSIS OF NONRECURSIVE ALGORITHMS There is ot a clear set of rules by which algorithms ca be aalysed. There are, however, a umber of techiques which appear agai ad agai. The best way to lear about these is really though examples. Algorithms cosist of sequeces of procedural steps which may themselves ivolve loops of fixed ( for... ) or idetermiate ( while, etc) legth, or of recursive fuctio calls (see later). We will start with the simplest cases: SEQUENTIAL OPERATIONS Step i O( f() ) Step (i+1) O( g() ) The combiatio of the ith ad (i+1)st steps takes a time i O( f() ) U O( g() ). Use O( f() ) U O( g() ) = O( max( f(),g() ) ) to justify eglectig all but the most time-costly step. COMPGC05: Part

15 Example: multiplicatio (i) Shift-ad-add multiplicatio ("log multiplicatio") x partial values bits i each umber logest is 2-1 bits result is 2 bits i worst case (1) Compute partial values, each requirig sigle-bit multiplicatios (2) Add the partial values (estimate as (-1) additios of pairs of (2-1)-bit umbers (upper boud)) Complexity (sigle-bit operatios) Step(1) 2 Step(2) (2-1)(-1) = Total O( 2 ) =5 example (19) (11) x5=25 sigle bit multiplicatios havig added top two rows (9 additios) havig added top two rows (9 additios) havig added top two rows (9 additios) havig added top two rows (9 additios) Total umber of sigle bit operatios = = 61 (= 3x5 2-3x5+1) As = = 0x256+1x128+1x64+0x32+1x16+0x8+0x4+0x2+1x1 = 209 COMPGC05: Part

16 (ii) A la russe method The idea is to start with two colums (where / i the first colum meas iteger divisio, ie droppig the remaider): a b a/2 2b a/4 4b i i i i 1 i Create a third colum, cotaiig a copy of the umber from the secod colum everywhere the umber i the first colum is odd. Add up this third colum to get the result. eg =209 There are O() etries i the colums, each ivolvig work O(1), sice each etry is made by either a right-shift (left colum) or by addig a zero (right colum). Addig the third colum is O( 2 ). So à la russe is also O( 2 ) overall but it s slightly faster tha shift-ad-add multiplicatio because it is still oly O() before the additio stage. Lower boud o the time-complexity of multiplicatio We argued earlier that every algorithm for multiplyig two -bit umbers will require at least 2 sigle-bit operatios, so has a best worst case i O(). There is thus scope for algorithms whose performace improves o that of the simple O( 2 ) oes above ad which have a worst-case performace somewhere i betwee O() ad O( 2 ), the best kow of which, Strasse s algorithm, has a worst-case performace i O( ). COMPGC05: Part

17 Sums of series Before movig o to look at algorithms with loops ad recursio, we eed to kow how to evaluate sums of series. Arithmetic series The otatio meas b i= a f (i) f(a)+f(a+1)+ +f(b). Note we ca use the otatio eve whe f is idepedet of i: b! c meas (c+c+ +c) = c(b-a+1) i=a!!! b-a+1 times The simplest ad most useful case is whe f(i) = i. I this case it is easy to derive a formula (a closed form which does ot have the summatio symbol) for f (i): b i= a 2 i= (-1) + i= (-1) =(+1)+ (+1)+ + (+1)+(+1) = (+1) copies i= 1 i= ( + 1) 2 COMPGC05: Part

18 It s sometimes the case that the sum to be evaluated does t start with i=1: i= i= j j 1 i - i i= 1 i= 1 ( j 1) = ( + 1) - j 2 2 Geometric series This is the other type of simple series summatio which is very useful i algorithmics. Let S() = a + a 2 + a a i = a a.s() = a 2 + a 3 + a a +1 = S() a + a +1 So i a(1 a ) a = for a 1 i= 1 1 a Note that the formula works oly for a 1 - if a=1 get sum 0/0, which gives a udefied value. The calculatio has to be doe differetly i this case: If a = 1: i a = i= 1 i= 1 1 = ( ) = terms i= 1 COMPGC05: Part

19 ALGORITHMS WITH LOOPS I the simplest cases where the loop is executed a fixed umber of times (a for loop) the complexity is just the cost of oe pass through the loop multiplied by the umber of iteratios. ALGORITHM Sum( A[0..-1] ) // Outputs the sum of the elemets i A[0..-1] sum < 0 for i < 0 to -1 do sum < sum + A[i] retur sum There is oly oe choice here for the elemetary operatio, additio. There are additios to 'sum' ad hece this takes time (measured by the umber of additios performed) i O(). Compare with this example from Leviti, p.61: ALGORITHM MaxElemet( A[0..-1] ) // Outputs the value of the largest elemet i A[0..-1] maxval < A[0] for i < 1 to -1 do if A[i] > maxval maxval < A[i] retur maxval I this case there are two operatios i the 'for' loop, compariso ad assigmet, that might be cadidates for the role of the elemetary operatio. However ote the assigmet is oly doe if the compariso returs true ad hece it is the compariso that gives the best measure of the worst case cost of the algorithm. As with the first example it's here easy to see the cost, i terms of the umber of comparisos, must be -1 ad hece this algorithms too is i O(). COMPGC05: Part

20 More formally-- Let C() be the cost of executig MaxElemet for a -elemet array. Coutig comparisos at uit cost!1 C() = " 1=!1 # O() i=1 * * * If there are several ested loops of this type the complexity is the cost of oe pass through the iermost loop multiplied by the total umber of iteratios. However for ay give loop the amout work doe may deped o the outer loop it is embedded i: for i < 1 to do for j < 1 to i do // somethig at uit cost The cost of the work here is i C() =!! 1=! i=1 j=1 i=1 (1 added to itself i times) =! i = (+1) (usig familiar formula for sum-of-i) 2 i=1 If you are asked to "simplify your aswer usig O-otatio" you are beig ivited to use the three rules o pp You ca use them iformally, you do't eed to quote the rules but you should bear them i mid ad make sure of your reasoig.! I this case sice O# " 2 (+1) $ & = O( max( 2 /2, /2 ) ) % = O( 2 /2) we just keep the leadig term, ad sice O(kf()) = O(f()) the 1/2 ca be dropped to give the work agai as O( 2 ). (I this case of questios askig you to "prove that f() is i the order of g()" the word "prove" implies you eed to use the formal defiitio of 'O' o p.9 ad oly this -- or aother equally formally structured mathematical argumet -- costitutes a full aswer.) COMPGC05: Part

21 A last loop example from Leviti (p.63): ALGORITHM UiqueElemets( A[0..-1] ) // Returs true if all elemets i A are distict, false otherwise for i < 0 to -2 do for j < i+1 to -1 do if A[i]=A[j] retur false retur true There is oly oe cadidate for elemetary operatio, the test 'A[i]=A[j]?' There are two worst case situatios: where the array cotais distict elemets (all passes through the ier loop are executed, with the coditioal evaluatig true every time); ad where oly the last two elemets A[-2], A[-1] are the same (as above but returs false o the very last test). I either of these situatios the cost of the work i terms of the umber of array elemet comparisos is!2!1 C() = "" 1= "(!1! (i +1) +1) = "(!1! i) i=0 j=i+1!2!2 i=0 = "(!1)!" i i=0!2!2 i=0 = (!1)" 1! " i i=0 (-1) is a costat w.r.t. the sum!2 i=1!2 i=0 the cotributio from i=0 is zero, so sum from i=1 for coveiece = (!1) 2! 1 (! 2)(!1) 2 use the sum-over-i formula with the upper limit adjusted = 2 (!1) " C() # O(2 ) ote this is the same as the umber of distict pairs should all array elemets be differet COMPGC05: Part

How do we evaluate algorithms?

How do we evaluate algorithms? F2 Readig referece: chapter 2 + slides Algorithm complexity Big O ad big Ω To calculate ruig time Aalysis of recursive Algorithms Next time: Litterature: slides mostly The first Algorithm desig methods:

More information

Lecture 1: Introduction and Strassen s Algorithm

Lecture 1: Introduction and Strassen s Algorithm 5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access

More information

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming

Lecture Notes 6 Introduction to algorithm analysis CSS 501 Data Structures and Object-Oriented Programming Lecture Notes 6 Itroductio to algorithm aalysis CSS 501 Data Structures ad Object-Orieted Programmig Readig for this lecture: Carrao, Chapter 10 To be covered i this lecture: Itroductio to algorithm aalysis

More information

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis

Analysis Metrics. Intro to Algorithm Analysis. Slides. 12. Alg Analysis. 12. Alg Analysis Itro to Algorithm Aalysis Aalysis Metrics Slides. Table of Cotets. Aalysis Metrics 3. Exact Aalysis Rules 4. Simple Summatio 5. Summatio Formulas 6. Order of Magitude 7. Big-O otatio 8. Big-O Theorems

More information

Algorithm. Counting Sort Analysis of Algorithms

Algorithm. Counting Sort Analysis of Algorithms Algorithm Coutig Sort Aalysis of Algorithms Assumptios: records Coutig sort Each record cotais keys ad data All keys are i the rage of 1 to k Space The usorted list is stored i A, the sorted list will

More information

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS)

CSC165H1 Worksheet: Tutorial 8 Algorithm analysis (SOLUTIONS) CSC165H1, Witer 018 Learig Objectives By the ed of this worksheet, you will: Aalyse the ruig time of fuctios cotaiig ested loops. 1. Nested loop variatios. Each of the followig fuctios takes as iput a

More information

Lecture 5. Counting Sort / Radix Sort

Lecture 5. Counting Sort / Radix Sort Lecture 5. Coutig Sort / Radix Sort T. H. Corme, C. E. Leiserso ad R. L. Rivest Itroductio to Algorithms, 3rd Editio, MIT Press, 2009 Sugkyukwa Uiversity Hyuseug Choo choo@skku.edu Copyright 2000-2018

More information

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8)

CIS 121 Data Structures and Algorithms with Java Fall Big-Oh Notation Tuesday, September 5 (Make-up Friday, September 8) CIS 11 Data Structures ad Algorithms with Java Fall 017 Big-Oh Notatio Tuesday, September 5 (Make-up Friday, September 8) Learig Goals Review Big-Oh ad lear big/small omega/theta otatios Practice solvig

More information

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n))

A graphical view of big-o notation. c*g(n) f(n) f(n) = O(g(n)) ca see that time required to search/sort grows with size of We How do space/time eeds of program grow with iput size? iput. time: cout umber of operatios as fuctio of iput Executio size operatio Assigmet:

More information

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance

Pseudocode ( 1.1) Analysis of Algorithms. Primitive Operations. Pseudocode Details. Running Time ( 1.1) Estimating performance Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Pseudocode ( 1.1) High-level descriptio of a algorithm More structured

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Ruig Time of a algorithm Ruig Time Upper Bouds Lower Bouds Examples Mathematical facts Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite

More information

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence

9.1. Sequences and Series. Sequences. What you should learn. Why you should learn it. Definition of Sequence _9.qxd // : AM Page Chapter 9 Sequeces, Series, ad Probability 9. Sequeces ad Series What you should lear Use sequece otatio to write the terms of sequeces. Use factorial otatio. Use summatio otatio to

More information

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time. Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects. The

More information

Big-O Analysis. Asymptotics

Big-O Analysis. Asymptotics Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses

More information

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies. Limitations of Experiments Ruig Time ( 3.1) Aalysis of Algorithms Iput Algorithm Output A algorithm is a step- by- step procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.

More information

Analysis of Algorithms

Analysis of Algorithms Aalysis of Algorithms Iput Algorithm Output A algorithm is a step-by-step procedure for solvig a problem i a fiite amout of time. Ruig Time Most algorithms trasform iput objects ito output objects. The

More information

Data Structures and Algorithms. Analysis of Algorithms

Data Structures and Algorithms. Analysis of Algorithms Data Structures ad Algorithms Aalysis of Algorithms Outlie Ruig time Pseudo-code Big-oh otatio Big-theta otatio Big-omega otatio Asymptotic algorithm aalysis Aalysis of Algorithms Iput Algorithm Output

More information

Ones Assignment Method for Solving Traveling Salesman Problem

Ones Assignment Method for Solving Traveling Salesman Problem Joural of mathematics ad computer sciece 0 (0), 58-65 Oes Assigmet Method for Solvig Travelig Salesma Problem Hadi Basirzadeh Departmet of Mathematics, Shahid Chamra Uiversity, Ahvaz, Ira Article history:

More information

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs

What are we going to learn? CSC Data Structures Analysis of Algorithms. Overview. Algorithm, and Inputs What are we goig to lear? CSC316-003 Data Structures Aalysis of Algorithms Computer Sciece North Carolia State Uiversity Need to say that some algorithms are better tha others Criteria for evaluatio Structure

More information

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis

Outline and Reading. Analysis of Algorithms. Running Time. Experimental Studies. Limitations of Experiments. Theoretical Analysis Outlie ad Readig Aalysis of Algorithms Iput Algorithm Output Ruig time ( 3.) Pseudo-code ( 3.2) Coutig primitive operatios ( 3.3-3.) Asymptotic otatio ( 3.6) Asymptotic aalysis ( 3.7) Case study Aalysis

More information

condition w i B i S maximum u i

condition w i B i S maximum u i ecture 10 Dyamic Programmig 10.1 Kapsack Problem November 1, 2004 ecturer: Kamal Jai Notes: Tobias Holgers We are give a set of items U = {a 1, a 2,..., a }. Each item has a weight w i Z + ad a utility

More information

Alpha Individual Solutions MAΘ National Convention 2013

Alpha Individual Solutions MAΘ National Convention 2013 Alpha Idividual Solutios MAΘ Natioal Covetio 0 Aswers:. D. A. C 4. D 5. C 6. B 7. A 8. C 9. D 0. B. B. A. D 4. C 5. A 6. C 7. B 8. A 9. A 0. C. E. B. D 4. C 5. A 6. D 7. B 8. C 9. D 0. B TB. 570 TB. 5

More information

Homework 1 Solutions MA 522 Fall 2017

Homework 1 Solutions MA 522 Fall 2017 Homework 1 Solutios MA 5 Fall 017 1. Cosider the searchig problem: Iput A sequece of umbers A = [a 1,..., a ] ad a value v. Output A idex i such that v = A[i] or the special value NIL if v does ot appear

More information

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times 2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times Lecture slides by Kevi Waye Copyright 2005 Pearso-Addiso

More information

1.2 Binomial Coefficients and Subsets

1.2 Binomial Coefficients and Subsets 1.2. BINOMIAL COEFFICIENTS AND SUBSETS 13 1.2 Biomial Coefficiets ad Subsets 1.2-1 The loop below is part of a program to determie the umber of triagles formed by poits i the plae. for i =1 to for j =

More information

CSE 417: Algorithms and Computational Complexity

CSE 417: Algorithms and Computational Complexity Time CSE 47: Algorithms ad Computatioal Readig assigmet Read Chapter of The ALGORITHM Desig Maual Aalysis & Sortig Autum 00 Paul Beame aalysis Problem size Worst-case complexity: max # steps algorithm

More information

Pattern Recognition Systems Lab 1 Least Mean Squares

Pattern Recognition Systems Lab 1 Least Mean Squares Patter Recogitio Systems Lab 1 Least Mea Squares 1. Objectives This laboratory work itroduces the OpeCV-based framework used throughout the course. I this assigmet a lie is fitted to a set of poits usig

More information

Examples and Applications of Binary Search

Examples and Applications of Binary Search Toy Gog ITEE Uiersity of Queeslad I the secod lecture last week we studied the biary search algorithm that soles the problem of determiig if a particular alue appears i a sorted list of iteger or ot. We

More information

Lower Bounds for Sorting

Lower Bounds for Sorting Liear Sortig Topics Covered: Lower Bouds for Sortig Coutig Sort Radix Sort Bucket Sort Lower Bouds for Sortig Compariso vs. o-compariso sortig Decisio tree model Worst case lower boud Compariso Sortig

More information

Big-O Analysis. Asymptotics

Big-O Analysis. Asymptotics Big-O Aalysis 1 Defiitio: Suppose that f() ad g() are oegative fuctios of. The we say that f() is O(g()) provided that there are costats C > 0 ad N > 0 such that for all > N, f() Cg(). Big-O expresses

More information

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0

Polynomial Functions and Models. Learning Objectives. Polynomials. P (x) = a n x n + a n 1 x n a 1 x + a 0, a n 0 Polyomial Fuctios ad Models 1 Learig Objectives 1. Idetify polyomial fuctios ad their degree 2. Graph polyomial fuctios usig trasformatios 3. Idetify the real zeros of a polyomial fuctio ad their multiplicity

More information

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70

Major CSL Write your name and entry no on every sheet of the answer script. Time 2 Hrs Max Marks 70 NOTE:. Attempt all seve questios. Major CSL 02 2. Write your ame ad etry o o every sheet of the aswer script. Time 2 Hrs Max Marks 70 Q No Q Q 2 Q 3 Q 4 Q 5 Q 6 Q 7 Total MM 6 2 4 0 8 4 6 70 Q. Write a

More information

. Written in factored form it is easy to see that the roots are 2, 2, i,

. Written in factored form it is easy to see that the roots are 2, 2, i, CMPS A Itroductio to Programmig Programmig Assigmet 4 I this assigmet you will write a java program that determies the real roots of a polyomial that lie withi a specified rage. Recall that the roots (or

More information

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved. Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4

More information

Analysis of Algorithms

Analysis of Algorithms Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Aalysis of Algorithms Iput 2015 Goodrich ad Tamassia Algorithm Aalysis of Algorithms

More information

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov

Sorting in Linear Time. Data Structures and Algorithms Andrei Bulatov Sortig i Liear Time Data Structures ad Algorithms Adrei Bulatov Algorithms Sortig i Liear Time 7-2 Compariso Sorts The oly test that all the algorithms we have cosidered so far is compariso The oly iformatio

More information

CSE 2320 Notes 8: Sorting. (Last updated 10/3/18 7:16 PM) Idea: Take an unsorted (sub)array and partition into two subarrays such that.

CSE 2320 Notes 8: Sorting. (Last updated 10/3/18 7:16 PM) Idea: Take an unsorted (sub)array and partition into two subarrays such that. CSE Notes 8: Sortig (Last updated //8 7:6 PM) CLRS 7.-7., 9., 8.-8. 8.A. QUICKSORT Cocepts Idea: Take a usorted (sub)array ad partitio ito two subarrays such that p q r x y z x y y z Pivot Customarily,

More information

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions

Lecturers: Sanjam Garg and Prasad Raghavendra Feb 21, Midterm 1 Solutions U.C. Berkeley CS170 : Algorithms Midterm 1 Solutios Lecturers: Sajam Garg ad Prasad Raghavedra Feb 1, 017 Midterm 1 Solutios 1. (4 poits) For the directed graph below, fid all the strogly coected compoets

More information

1 Graph Sparsfication

1 Graph Sparsfication CME 305: Discrete Mathematics ad Algorithms 1 Graph Sparsficatio I this sectio we discuss the approximatio of a graph G(V, E) by a sparse graph H(V, F ) o the same vertex set. I particular, we cosider

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19

CIS 121 Data Structures and Algorithms with Java Spring Stacks, Queues, and Heaps Monday, February 18 / Tuesday, February 19 CIS Data Structures ad Algorithms with Java Sprig 09 Stacks, Queues, ad Heaps Moday, February 8 / Tuesday, February 9 Stacks ad Queues Recall the stack ad queue ADTs (abstract data types from lecture.

More information

prerequisites: 6.046, 6.041/2, ability to do proofs Randomized algorithms: make random choices during run. Main benefits:

prerequisites: 6.046, 6.041/2, ability to do proofs Randomized algorithms: make random choices during run. Main benefits: Itro Admiistrivia. Sigup sheet. prerequisites: 6.046, 6.041/2, ability to do proofs homework weekly (first ext week) collaboratio idepedet homeworks gradig requiremet term project books. questio: scribig?

More information

Octahedral Graph Scaling

Octahedral Graph Scaling Octahedral Graph Scalig Peter Russell Jauary 1, 2015 Abstract There is presetly o strog iterpretatio for the otio of -vertex graph scalig. This paper presets a ew defiitio for the term i the cotext of

More information

The isoperimetric problem on the hypercube

The isoperimetric problem on the hypercube The isoperimetric problem o the hypercube Prepared by: Steve Butler November 2, 2005 1 The isoperimetric problem We will cosider the -dimesioal hypercube Q Recall that the hypercube Q is a graph whose

More information

Module 8-7: Pascal s Triangle and the Binomial Theorem

Module 8-7: Pascal s Triangle and the Binomial Theorem Module 8-7: Pascal s Triagle ad the Biomial Theorem Gregory V. Bard April 5, 017 A Note about Notatio Just to recall, all of the followig mea the same thig: ( 7 7C 4 C4 7 7C4 5 4 ad they are (all proouced

More information

UNIT 1 RECURRENCE RELATIONS

UNIT 1 RECURRENCE RELATIONS UNIT RECURRENCE RELATIONS Structure Page No.. Itroductio 7. Objectives 7. Three Recurret Problems 8.3 More Recurreces.4 Defiitios 4.5 Divide ad Coquer 7.6 Summary 9.7 Solutios/Aswers. INTRODUCTION I the

More information

EE123 Digital Signal Processing

EE123 Digital Signal Processing Last Time EE Digital Sigal Processig Lecture 7 Block Covolutio, Overlap ad Add, FFT Discrete Fourier Trasform Properties of the Liear covolutio through circular Today Liear covolutio with Overlap ad add

More information

Chapter 3 Classification of FFT Processor Algorithms

Chapter 3 Classification of FFT Processor Algorithms Chapter Classificatio of FFT Processor Algorithms The computatioal complexity of the Discrete Fourier trasform (DFT) is very high. It requires () 2 complex multiplicatios ad () complex additios [5]. As

More information

The Magma Database file formats

The Magma Database file formats The Magma Database file formats Adrew Gaylard, Bret Pikey, ad Mart-Mari Breedt Johaesburg, South Africa 15th May 2006 1 Summary Magma is a ope-source object database created by Chris Muller, of Kasas City,

More information

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions

A Generalized Set Theoretic Approach for Time and Space Complexity Analysis of Algorithms and Functions Proceedigs of the 10th WSEAS Iteratioal Coferece o APPLIED MATHEMATICS, Dallas, Texas, USA, November 1-3, 2006 316 A Geeralized Set Theoretic Approach for Time ad Space Complexity Aalysis of Algorithms

More information

Numerical Methods Lecture 6 - Curve Fitting Techniques

Numerical Methods Lecture 6 - Curve Fitting Techniques Numerical Methods Lecture 6 - Curve Fittig Techiques Topics motivatio iterpolatio liear regressio higher order polyomial form expoetial form Curve fittig - motivatio For root fidig, we used a give fuctio

More information

One advantage that SONAR has over any other music-sequencing product I ve worked

One advantage that SONAR has over any other music-sequencing product I ve worked *gajedra* D:/Thomso_Learig_Projects/Garrigus_163132/z_productio/z_3B2_3D_files/Garrigus_163132_ch17.3d, 14/11/08/16:26:39, 16:26, page: 647 17 CAL 101 Oe advatage that SONAR has over ay other music-sequecig

More information

Civil Engineering Computation

Civil Engineering Computation Civil Egieerig Computatio Fidig Roots of No-Liear Equatios March 14, 1945 World War II The R.A.F. first operatioal use of the Grad Slam bomb, Bielefeld, Germay. Cotets 2 Root basics Excel solver Newto-Raphso

More information

CS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts

CS 111 Green: Program Design I Lecture 27: Speed (cont.); parting thoughts CS 111 Gree: Program Desig I Lecture 27: Speed (cot.); partig thoughts By Nascarkig - Ow work, CC BY-SA 4.0, https://commos.wikimedia.org/w/idex.php?curid=38671041 Robert H. Sloa (CS) & Rachel Poretsky

More information

Counting Regions in the Plane and More 1

Counting Regions in the Plane and More 1 Coutig Regios i the Plae ad More 1 by Zvezdelia Stakova Berkeley Math Circle Itermediate I Group September 016 1. Overarchig Problem Problem 1 Regios i a Circle. The vertices of a polygos are arraged o

More information

Elementary Educational Computer

Elementary Educational Computer Chapter 5 Elemetary Educatioal Computer. Geeral structure of the Elemetary Educatioal Computer (EEC) The EEC coforms to the 5 uits structure defied by vo Neuma's model (.) All uits are preseted i a simplified

More information

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem

Exact Minimum Lower Bound Algorithm for Traveling Salesman Problem Exact Miimum Lower Boud Algorithm for Travelig Salesma Problem Mohamed Eleiche GeoTiba Systems mohamed.eleiche@gmail.com Abstract The miimum-travel-cost algorithm is a dyamic programmig algorithm to compute

More information

Protected points in ordered trees

Protected points in ordered trees Applied Mathematics Letters 008 56 50 www.elsevier.com/locate/aml Protected poits i ordered trees Gi-Sag Cheo a, Louis W. Shapiro b, a Departmet of Mathematics, Sugkyukwa Uiversity, Suwo 440-746, Republic

More information

MATHEMATICAL METHODS OF ANALYSIS AND EXPERIMENTAL DATA PROCESSING (Or Methods of Curve Fitting)

MATHEMATICAL METHODS OF ANALYSIS AND EXPERIMENTAL DATA PROCESSING (Or Methods of Curve Fitting) MATHEMATICAL METHODS OF ANALYSIS AND EXPERIMENTAL DATA PROCESSING (Or Methods of Curve Fittig) I this chapter, we will eamie some methods of aalysis ad data processig; data obtaied as a result of a give

More information

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle:

Recursion. Recursion. Mathematical induction: example. Recursion. The sum of the first n odd numbers is n 2 : Informal proof: Principle: Recursio Recursio Jordi Cortadella Departmet of Computer Sciece Priciple: Reduce a complex problem ito a simpler istace of the same problem Recursio Itroductio to Programmig Dept. CS, UPC 2 Mathematical

More information

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5 Morga Kaufma Publishers 26 February, 28 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Set-Associative Cache Architecture Performace Summary Whe CPU performace icreases:

More information

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3

More information

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Part A Datapath Design COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter The Processor Part A path Desig Itroductio CPU performace factors Istructio cout Determied by ISA ad compiler. CPI ad

More information

the beginning of the program in order for it to work correctly. Similarly, a Confirm

the beginning of the program in order for it to work correctly. Similarly, a Confirm I our sytax, a Assume statemet will be used to record what must be true at the begiig of the program i order for it to work correctly. Similarly, a Cofirm statemet is used to record what should be true

More information

UNIT 4C Iteration: Scalability & Big O. Efficiency

UNIT 4C Iteration: Scalability & Big O. Efficiency UNIT 4C Iteratio: Scalability & Big O 1 Efficiecy A computer program should be totally correct, but it should also execute as quickly as possible (time-efficiecy) use memory wisely (storage-efficiecy)

More information

Data Structures Week #9. Sorting

Data Structures Week #9. Sorting Data Structures Week #9 Sortig Outlie Motivatio Types of Sortig Elemetary (O( 2 )) Sortig Techiques Other (O(*log())) Sortig Techiques 21.Aralık.2010 Boraha Tümer, Ph.D. 2 Sortig 21.Aralık.2010 Boraha

More information

Computational Geometry

Computational Geometry Computatioal Geometry Chapter 4 Liear programmig Duality Smallest eclosig disk O the Ageda Liear Programmig Slides courtesy of Craig Gotsma 4. 4. Liear Programmig - Example Defie: (amout amout cosumed

More information

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames

Recursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of

More information

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13

CIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13 CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis

More information

Algorithm Design Techniques. Divide and conquer Problem

Algorithm Design Techniques. Divide and conquer Problem Algorithm Desig Techiques Divide ad coquer Problem Divide ad Coquer Algorithms Divide ad Coquer algorithm desig works o the priciple of dividig the give problem ito smaller sub problems which are similar

More information

CMPT 125 Assignment 2 Solutions

CMPT 125 Assignment 2 Solutions CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address

More information

It just came to me that I 8.2 GRAPHS AND CONVERGENCE

It just came to me that I 8.2 GRAPHS AND CONVERGENCE 44 Chapter 8 Discrete Mathematics: Fuctios o the Set of Natural Numbers (a) Take several odd, positive itegers for a ad write out eough terms of the 3N sequece to reach a repeatig loop (b) Show that ot

More information

Arithmetic Sequences

Arithmetic Sequences . Arithmetic Sequeces COMMON CORE Learig Stadards HSF-IF.A. HSF-BF.A.1a HSF-BF.A. HSF-LE.A. Essetial Questio How ca you use a arithmetic sequece to describe a patter? A arithmetic sequece is a ordered

More information

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig

More information

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness

Sorting 9/15/2009. Sorting Problem. Insertion Sort: Soundness. Insertion Sort. Insertion Sort: Running Time. Insertion Sort: Soundness 9/5/009 Algorithms Sortig 3- Sortig Sortig Problem The Sortig Problem Istace: A sequece of umbers Objective: A permutatio (reorderig) such that a ' K a' a, K,a a ', K, a' of the iput sequece The umbers

More information

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract

On Infinite Groups that are Isomorphic to its Proper Infinite Subgroup. Jaymar Talledo Balihon. Abstract O Ifiite Groups that are Isomorphic to its Proper Ifiite Subgroup Jaymar Talledo Baliho Abstract Two groups are isomorphic if there exists a isomorphism betwee them Lagrage Theorem states that the order

More information

LU Decomposition Method

LU Decomposition Method SOLUTION OF SIMULTANEOUS LINEAR EQUATIONS LU Decompositio Method Jamie Traha, Autar Kaw, Kevi Marti Uiversity of South Florida Uited States of America kaw@eg.usf.edu http://umericalmethods.eg.usf.edu Itroductio

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe CHAPTER 18 Strategies for Query Processig Copyright 2016 Ramez Elmasri ad Shamkat B. Navathe Itroductio DBMS techiques to process a query Scaer idetifies

More information

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures Uiversity of Waterloo Departmet of Electrical ad Computer Egieerig ECE 250 Algorithms ad Data Structures Midterm Examiatio ( pages) Istructor: Douglas Harder February 7, 2004 7:30-9:00 Name (last, first)

More information

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup Note:

Abstract. Chapter 4 Computation. Overview 8/13/18. Bjarne Stroustrup   Note: Chapter 4 Computatio Bjare Stroustrup www.stroustrup.com/programmig Abstract Today, I ll preset the basics of computatio. I particular, we ll discuss expressios, how to iterate over a series of values

More information

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method

A New Morphological 3D Shape Decomposition: Grayscale Interframe Interpolation Method A ew Morphological 3D Shape Decompositio: Grayscale Iterframe Iterpolatio Method D.. Vizireau Politehica Uiversity Bucharest, Romaia ae@comm.pub.ro R. M. Udrea Politehica Uiversity Bucharest, Romaia mihea@comm.pub.ro

More information

Fast Fourier Transform (FFT) Algorithms

Fast Fourier Transform (FFT) Algorithms Fast Fourier Trasform FFT Algorithms Relatio to the z-trasform elsewhere, ozero, z x z X x [ ] 2 ~ elsewhere,, ~ e j x X x x π j e z z X X π 2 ~ The DFS X represets evely spaced samples of the z- trasform

More information

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions:

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring, Instructions: CS 604 Data Structures Midterm Sprig, 00 VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Istructios: Prit your ame i the space provided below. This examiatio is closed book ad closed

More information

ECE4050 Data Structures and Algorithms. Lecture 6: Searching

ECE4050 Data Structures and Algorithms. Lecture 6: Searching ECE4050 Data Structures ad Algorithms Lecture 6: Searchig 1 Search Give: Distict keys k 1, k 2,, k ad collectio L of records of the form (k 1, I 1 ), (k 2, I 2 ),, (k, I ) where I j is the iformatio associated

More information

CS 683: Advanced Design and Analysis of Algorithms

CS 683: Advanced Design and Analysis of Algorithms CS 683: Advaced Desig ad Aalysis of Algorithms Lecture 6, February 1, 2008 Lecturer: Joh Hopcroft Scribes: Shaomei Wu, Etha Feldma February 7, 2008 1 Threshold for k CNF Satisfiability I the previous lecture,

More information

CIS 121. Introduction to Trees

CIS 121. Introduction to Trees CIS 121 Itroductio to Trees 1 Tree ADT Tree defiitio q A tree is a set of odes which may be empty q If ot empty, the there is a distiguished ode r, called root ad zero or more o-empty subtrees T 1, T 2,

More information

Data Structures and Algorithms Part 1.4

Data Structures and Algorithms Part 1.4 1 Data Structures ad Algorithms Part 1.4 Werer Nutt 2 DSA, Part 1: Itroductio, syllabus, orgaisatio Algorithms Recursio (priciple, trace, factorial, Fiboacci) Sortig (bubble, isertio, selectio) 3 Sortig

More information

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1 COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,

More information

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence?

Recursive Procedures. How can you model the relationship between consecutive terms of a sequence? 6. Recursive Procedures I Sectio 6.1, you used fuctio otatio to write a explicit formula to determie the value of ay term i a Sometimes it is easier to calculate oe term i a sequece usig the previous terms.

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpeCourseWare http://ocw.mit.edu 6.854J / 18.415J Advaced Algorithms Fall 2008 For iformatio about citig these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advaced Algorithms

More information

Perhaps the method will give that for every e > U f() > p - 3/+e There is o o-trivial upper boud for f() ad ot eve f() < Z - e. seems to be kow, where

Perhaps the method will give that for every e > U f() > p - 3/+e There is o o-trivial upper boud for f() ad ot eve f() < Z - e. seems to be kow, where ON MAXIMUM CHORDAL SUBGRAPH * Paul Erdos Mathematical Istitute of the Hugaria Academy of Scieces ad Reu Laskar Clemso Uiversity 1. Let G() deote a udirected graph, with vertices ad V(G) deote the vertex

More information

Ch 9.3 Geometric Sequences and Series Lessons

Ch 9.3 Geometric Sequences and Series Lessons Ch 9.3 Geometric Sequeces ad Series Lessos SKILLS OBJECTIVES Recogize a geometric sequece. Fid the geeral, th term of a geometric sequece. Evaluate a fiite geometric series. Evaluate a ifiite geometric

More information

Math 3201 Notes Chapter 4: Rational Expressions & Equations

Math 3201 Notes Chapter 4: Rational Expressions & Equations Learig Goals: See p. tet.. Equivalet Ratioal Epressios ( classes) Read Goal p. 6 tet. Math 0 Notes Chapter : Ratioal Epressios & Equatios. Defie ad give a eample of a ratioal epressio. p. 6. Defie o-permissible

More information

The Adjacency Matrix and The nth Eigenvalue

The Adjacency Matrix and The nth Eigenvalue Spectral Graph Theory Lecture 3 The Adjacecy Matrix ad The th Eigevalue Daiel A. Spielma September 5, 2012 3.1 About these otes These otes are ot ecessarily a accurate represetatio of what happeed i class.

More information

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms

Chapter 24. Sorting. Objectives. 1. To study and analyze time efficiency of various sorting algorithms Chapter 4 Sortig 1 Objectives 1. o study ad aalyze time efficiecy of various sortig algorithms 4. 4.7.. o desig, implemet, ad aalyze bubble sort 4.. 3. o desig, implemet, ad aalyze merge sort 4.3. 4. o

More information

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.

Hash Tables. Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015. Presetatio for use with the textbook Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Hash Tables xkcd. http://xkcd.com/221/. Radom Number. Used with permissio uder Creative

More information

Improved Random Graph Isomorphism

Improved Random Graph Isomorphism Improved Radom Graph Isomorphism Tomek Czajka Gopal Paduraga Abstract Caoical labelig of a graph cosists of assigig a uique label to each vertex such that the labels are ivariat uder isomorphism. Such

More information

15 UNSUPERVISED LEARNING

15 UNSUPERVISED LEARNING 15 UNSUPERVISED LEARNING [My father] advised me to sit every few moths i my readig chair for a etire eveig, close my eyes ad try to thik of ew problems to solve. I took his advice very seriously ad have

More information

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved. Chapter 4 Procedural Abstractio ad Fuctios That Retur a Value Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 4.1 Top-Dow Desig 4.2 Predefied Fuctios 4.3 Programmer-Defied Fuctios 4.4

More information

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control EE 459/500 HDL Based Digital Desig with Programmable Logic Lecture 13 Cotrol ad Sequecig: Hardwired ad Microprogrammed Cotrol Refereces: Chapter s 4,5 from textbook Chapter 7 of M.M. Mao ad C.R. Kime,

More information