3 Pages

L-12

Course: CPS 230, Fall 2009
School: Duke
Rating:
 
 
 
 
 

Word Count: 1741

Document Preview

12 October Meeting 6, 2005 Solving Recurrence Relations Recurrence relations are perhaps the most important tool in the analysis of algorithms. We have encountered several methods that can sometimes be used to solve such relations, such as guessing the solution and proving it by induction and developing the relation into a sum for which we find a closed form expression. We now describe a new method to solve...

Register Now

Unformatted Document Excerpt

Coursehero >> North Carolina >> Duke >> CPS 230

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
12 October Meeting 6, 2005 Solving Recurrence Relations Recurrence relations are perhaps the most important tool in the analysis of algorithms. We have encountered several methods that can sometimes be used to solve such relations, such as guessing the solution and proving it by induction and developing the relation into a sum for which we find a closed form expression. We now describe a new method to solve recurrence relations and use it to settle the remaining open question in the analysis of Fibonacci heaps. Annihilation of sequences. Suppose we are given an infinite sequence of numbers, A = a0 , a1 , a2 , . . . . We can multiply with a constant, shift to the left and add another sequence: kA = LA = A+B = ka0 , ka1 , ka2 , . . . , a 1 , a2 , a3 , . . . , a 0 + b 0 , a1 + b 1 , a2 + b 2 , . . . . Multiple operators. Instead of just one, we can apply several operators to a sequence. We may multiply with two constants, k( A) = (k )A, multiply and shift, L(kA) = k(LA), and shift twice, L(LA) = L2 A. For example, (L - k)(L - ) annihilates all sequences of the form ck i + d i , where we assume k = . Indeed, L - k annihilates ck i and leaves behind ( - k)d i , which is annihilated by L - . Furthermore, (L - k)(L - ) annihilates no other sequences. More generally, we have FACT. (L - k1 )(L - k2 ) . . . (L - kn ) annihilates all sei i i quences of the form c1 k1 + c2 k2 + . . . + cn kn . What if k = ? To answer this question consider (L - k)2 ik i = (L - k) (i + 1)k i+1 - ik i+1 = (L - k) k i+1 = 0. As an example, consider the sequence of powers of two, ai = 2i . Multiplying with 2 and shifting to the left give the same result. Therefore, LA - 2A = 0, 0, 0, . . . . More generally, we have FACT. (L - k)n annihilates all sequences of the form p(i)k i , with p(i) a polynomial of degree n - 1. Since operators annihilate only certain types of sequences, we can determine the sequence if we know the annihilating operator. The general method works in five steps: 1. Write down the annihilator for the recurrence. 2. Factor the annihilator. 3. Determine what sequence each factor annihilates. 4. Put the sequences together. 5. Solve for the constants of the solution by using initial conditions. We write LA - 2A = (L - 2)A and think of L - 2 as an operator that annihilates the sequence of powers of 2. In general, L - k annihilates any sequence of the form ck i . What does L - k do to other sequences A = c i , when = k? (L - k)A = c , c 2 , c 3 , . . . - ck, ck , ck 2 , . . . = ( - k) c, c , c 2 , . . . = ( - k)A. We see that the operator L - k annihilates only one type of sequence and multiplies other similar sequences by a constant. 38 Fibonacci numbers. We put the method to a test by considering the Fibonacci numbers defined recursively as follows: F0 F1 Fj = 0, = 1, = Fj-1 + Fj-2 , for j 2. Maximum degree. Recall that D(n) is the maximum possible degree of any one node in a Fibonacci heap of size n. We need two easy facts about the kind of trees that arise in Fibonacci heaps in order to show that D(n) is at most logarithmic in n. Let be a node of degree j, and let 1 , 2 , . . . , j be its children ordered by the time they were linked to . D EGREE L EMMA . The degree of i is at least i - 2. P ROOF. Recall that nodes are linked only during the deletemin operation. Right before the linking happens (and one nodes becomes a child of the other) the two nodes are roots and have the same degree. It follows that the degree of i was at least i - 1 at the time it was linked to . The degree of i might have been even higher because it is possible that lost some of the older children after i had been linked. After being linked, i may have lost at most one of its children, for else it would have been cut. Its degree is therefore at least i - 2, as claimed. S IZE L EMMA . The number of descendents of (including ) is at least Fj+2 . P ROOF. Let sj be the minimum number of descendents a node of degree j can have. We have s0 = 1 and s1 = 2. For larger j, we get sj from sj-1 by adding the size of a minimum tree with root degree j-2, which is sj-2 . Hence sj = sj-1 + sj-2 , which is the same recurrence relation that defines the Fibonacci numbers. The initial values are shifted two positions so we get sj = Fj+2 , as claimed. Consider a Fibonacci heap with n nodes and let be a node with maximum degree D = D(n). The Size Lemma implies n FD+2 . The Fibonacci number with index D + 2 is roughly D+2 / 5. Because D+2 < 5, we have n 1 D+2 - 1. 5 Writing a few of the initial numbers, we get the sequence 0, 1, 1, 2, 3, 5, 8, . . . . We notice that L2 - L - 1 annihilates the sequence because (L2 - L - 1) Fj = L 2 Fj - L F j - F j = = Fj+2 - Fj+1 - Fj 0. If we factor the operator into its roots, we get L2 - L - 1 = (L - )(L - ), where = 1- = = 1+ 5 = 1.618 . . . , 2 1- 5 = - 0.618 . . . . 2 The first root is known as golden the ratio because it represents the aspect ratio of a rectangular piece of paper from which we may remove a square to leave a smaller rectangular piece of the same ratio: : 1 = 1 : - 1. Thus we know that (L - )(L - ) annihilates Fj and this means that the j-th Fibonacci number is of the form Fj = cj + c j . We get the constant factors from the initial conditions: F0 F1 = 0 = c + c, = 1 = c + c . Solving the two linear equations in two unknowns, we get c = 1/ 5 and c = -1/ 5. This implies that Fj = 1 5 1+ 5 2 j 1 - 5 1- 5 2 j . After rearranging the terms and taking the logarithm to the base , we get D log 5(n + 1) - 2. From this viewpoint, it seems surprising that Fj turns out to be an integer for all j. Note that || > 1 and || < 1. It follows that for growing exponent j, j goes to infinity and j goes to zero. This implies that Fj is approximately j / 5, and that this approximation becomes more and more accurate as j grows. Recall that log x = log2 x/ log2 and use the calculator to verify that log2 = 0.694 . . . > 0.5 and log 5 = 1.672 . . . < 2. Hence D log2 (n + 1) + log 5 - 2 log2 < 2 log2 (n + 1). 39 Non-homogeneous terms. We now return to the annihilation method for solving recurrence relations and consider aj = aj-1 + aj-2 + 1. The running time is described by the solution to the recurrence T (1) = 1, T (n) = 2T (n/2) + n. We have no way to work with terms like T (n/2) yet. However, we can transform the recurrence into a more manageable form. Defining n = 2i and ti = T (2i ) we get t0 ti = 1, = 2ti-1 + 2i . This is similar to the recurrence that defines Fibonacci numbers and describes the minimum number of nodes in an AVL tree, also known as height-balanced tree. It is defined by the requirement that the height of the two subtrees of a node differ by at most 1. The smallest tree of height j thus consists of the root, a subtree of height j - 1 and another subtree of height j - 2. We refer to the terms involving ai as the homogeneous terms of the relation and the others as the non-homogeneous terms. We know that L2 - L - 1 annihilates the homogeneous part, aj = aj-1 + aj-2 . If we apply it to the entire relation we get (L2 - L - 1) aj = = aj+2 - aj+1 - aj 1, 1, . . . . The homogeneous part is annihilated by L - 2. Similarly, non-homogeneous part is annihilated by L - 2. Hence, (L - 2)2 annihilates the entire relation and we get ti = (ci + c)2i . Expressed in the original notation we thus have T (n) = (c log2 n + c)n = O(n log n). This result is of course no surprise and reconfirms what we learned earlier about sorting. The Master Theorem. It is sometimes more convenient to look up the solution to a recurrence relation than playing with different techniques to see whether any one can make it to yield. Such a cookbook method for recurrence relations of the form T (n) = aT (n/b) + f (n) is provided by the following theorem. He...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Duke - CPS - 230
Homework Assignment 1September 13, 2005Homework on Design TechniquesWrite the solution to each problem on a single page. The deadline for handing in solutions is September 22.Problem 1. (20 = 12 + 8 points). Sort a linear array A[1.n] with B U
Duke - CPS - 230
Meeting 10September 29, 2005Heaps and HeapsortA heap is a data structure that stores a set and allows fast access to the item with highest priority. It is the basis of a fast implementation of selection sort. On the average this algorithm is a
Duke - CPS - 230
Meeting 3September 6, 2005Prune-and-SearchWe use two algorithms for selection as examples for the prune-and-search paradigm. The problem is to nd the i-smallest item in an unsorted collection of n items. We could rst sort the list and then retu
Duke - CPS - 108
Working as part of a groupsee McCarthy, Dynamics of Software Developmentestablish a shared vision what was/is Freecell? what can we add? harmonious sense of purpose develop a creative environment the more ideas the better, ideas are infectious don
Duke - CPS - 102
The Zebra PuzzleCarlo Tomasi Computer Science Duke University1IntroductionIn the class textbook, the Zebra puzzle is offered as an exercise for Section 1.1 on logic (Exercise 61, page 20). Here is the puzzle: Five men with different nationalit
Duke - CPS - 108
multi-platform, multi-os client/serverSuppose we send data between clients and servers Architectural issues impact client/server code Little-endian/Big-endian issues 0xabcd is a 32-bit value, which is MSB? How is this stored?How big is an int? 32
Duke - CPS - 230
Meeting 11October 4, 2005Fibonacci HeapsThe Fibonacci heap is a data structure implementing the priority queue abstract data type, just like the ordinary heap but more complicated and asymptotically faster for some operations. We rst introduce
Duke - CPS - 234
CPS234 Computational GeometrySeptember 22nd, 2005Lecture 8: Orthogonal Range SearchingLecturer: Pankaj K. Agarwal Scribe: Mason F. Matthews8.1 Range SearchingThe general problem of range searching is as follows: Given input S, a set of n poin
Duke - CPS - 110
Xen&amp;LinuxKernel ProgrammingAddingaSystemCallIonutConstandacheWhatisXen? Avirtualmachinemonitor(VMM)forx86compatiblecomputersRunmultipleinstancesofOSessimultaneously ProvidesisolationbetweenGuestOSes DoesnothidevirtualizationfromtheGues
Duke - CPS - 196
X v IhtIdV`RP Hw U sXTY Y tIIdIVuVg 7d7IdY v eUeUUT E WUTU vTY sQ g HXQ WP IGt7VT dGIU dVT UgT WY WUY GV7Q `VIG5I7ddRP X v I`V7IGf HWX 7 HwY v f&quot;xR&quot;c R&quot; xi r&quot; x dr f Rc xcxcR fd &quot; Ri9 rx&quot;f hd f RccR
Duke - CPS - 250
Duke UniversityDepartment of Computer Science CPS 250: Numerical Analysis Spring, 2007Time: 11:40am 12:55pm TuTh Instructor: Xiaobai Sun Oce Location: D107 LSRC Email: xiaobai@cs.duke.edu Prerequisites:Class location: D243 LSRC TAs: Mingyu Guo
Duke - CPS - 296
Sponsored Search: a Brief HistoryYahoo! Inc. 3333 Empire Ave. Burbank CA 91504 USA (818) 524-3000Daniel C. FainYahoo! Inc. 701 First Ave. Sunnyvale CA 94089 USA (408) 439-3300Jan O. Pedersenfaind@yahoo-inc.com ABSTRACT4. 5.jpederse@yahoo-
Duke - CPS - 296
Distortion Estimation Techniques in Solving Visual CAPTCHAsGabriel Moy, Nathan Jones, Curt Harkless, and Randall PotterAret Associates e Sherman Oaks, CA 91403 Email: {moy,jones,harkless,potter}@arete.comAbstract This paper describes two distorti
Duke - CPS - 296
L e a r n i n g t o C o o r d i n a t e A c t i o n s i n M u l t i - A g e n t SystemsGerhard WeiB I n s t i t u t fur l n f o r m a t i k , Technische Universitat Miinchen Arcisstr. 2 1 , 8000 Miinchen 2, Germany weissg@informatik.tu-muenchen.de
Duke - CPS - 049
Discussion Report: The Anatomy of a Large scale Hypertextual Web Search EngineAzbayar Demberel Department of Computer Science asic@cs.duke.edu1The World Before GoogleWith the birth of the World Wide Web (WWW), the usage of the Internet has gro
Duke - CPS - 296
Peekaboom: A Game for Locating Objects in ImagesLuis von Ahn, Ruoran Liu and Manuel Blum Computer Science Department, Carnegie Mellon University 5000 Forbes Avenue, Pittsburgh PA 15213 {biglou, royliu, mblum}@cs.cmu.eduABSTRACTWe introduce Peekab
Duke - CPS - 049
CPS 49S Google: The Computer Science Within and its Impact on Society - Spring 2007 Homework 4 Due date: Wednesday, April 18, 2007, 11.59 PM. Late submissions will not be accepted (unless there are documented excuses from the dean). Submission: In
Duke - CPS - 049
Chapter 9: Google Goes Public Chapter 10: Google Today, Google Tomorrow Neel Vora Discussion Report: 3/29/07Should Google go Public?Chapter Nine of The Search: How Google and Its Rivals Rewrote the Rules of Business and Transformed Our Culture foc
Duke - CPS - 140
CPS 140Project 1 Project Due: Thursday, Feb. 8, 11:59pm 30 pointsSpring 2007An elementary school would like to have a simple animation program to teach kids a little bit about computer science, in particular how programming works. Many of the k
Duke - CPS - 049
Discussion Report: The Anatomy of a Large scale Hypertextual Web Search Engine (part 2)Azbayar Demberel Department of Computer Science asic@cs.duke.edu January 24, 200711.1System designData structuresA good search engine is not just a clever
Duke - CPS - 296
Quantifying Incentive Compatibility of Ranking SystemsAlon Altman Moshe Tennenholtz 15th March 2006Abstract Reasoning about agent preferences on a set of alternatives, and the aggregation of such preferences into some social ranking is a fundamenta
Duke - CPS - 296
Truthful Auctions for Pricing Search Keywords Gagan Aggarwal Google Inc. Ashish Goel Stanford University March 12, 2006 Rajeev Motwani Stanford UniversityAbstract We present a truthful auction for pricing advertising slots on a web-page assumin
Duke - CPS - 049
CPS 49S Google: The Computer Science Within and its Impact on Society - Spring 2007 Homework 1 Due date: Tuesday, Jan 30, 2007, in class (2.50 PM). Late submissions will not be accepted (unless there are documented excuses from the dean). Submissi
Duke - CPS - 001
Todays topicsNetworks &amp; the Internet Basic HTML The basis for web pages Almost programming Upcoming Connections Algorithms Reading Internet history readings Great Ideas Chapters 1 Computer Science, Chapter 4CompSci 001 2.1NetworksNeed to communi
Duke - CPS - 001
Outline of implementationRSA algorithm for key generation select two prime numbers p, q compute n = p q v = (p-1) (q-1) select small odd integer k such that gcd(k, v) = 1 compute d such that (d k)%v = 1 RSA algorithm for encryption/decryption encryp
Duke - CPS - 001
1 WHAT YOU SHOULD KNOW (and More) FOR THE LAB FINALExplanation of JavaWhat is an object? o An object is a value of a class type o An example is: String, Sound or a Robot What is a primitive type? o A primitive type is a number type or Boolean typ
Duke - CPS - 001
Todays topicsBinary Numbers Brookshear 1.1-1.6 Slides from Prof. Marti Hearst of UC Berkeley SIMS Upcoming Networks Interactive Introduction to Graph Theoryhttp:/www.utm.edu/cgi-bin/caldwell/tutor/departments/math/graph/introDigital ComputersWh
Duke - CPS - 001
Normalize Sounds Make the whole sound as loud as possible How loud can it be? The max positive value is 32767 The max negative value is -32768Creating a Sound Clip To clip the This out of This is a test. Determine where it starts and stops U
Duke - CPS - 001
Today's topicsRevisiting numbers &amp; text Methods Loops Arrays Reading Great Ideas, Chapter 4Types for NumbersThe type String is not a built-in type, technically it's a class There are many numerical types in Java We'll use two int, represents inte
Duke - CPS - 001
Welcome!Principles of Computer Science CompSci 1 LSRC B101 M, W, F 10:20-11:10 Professor Jeff ForbesTodays topicsWhat is this course about? How are we going to learn that? Who is this guy talking to us? Where do we go from here? An overview of co
Duke - CPS - 170
Historical Perspective I Logic IntroCPS 170 Ron Parr Logic was one of the classical foundations of AI Dream: A Knowledge-Based agent Tell the agent facts Agent uses rules of inference to deduce consequences Example: prolog Distinction between
Duke - CPS - 170
Why Study Games? Many human activities can be modeled as games Negotiations Bidding TCP/IP Military confrontations Pursuit/EvasionGamesCPS 170 Ron Parr Games are used to train the mind Human game-playing, animal play-fightingWhy Are Gam
Duke - CPS - 270
COMPSCI 270 - Articial Intelligence Project I Playing the Game of OthelloDue date: September 291DescriptionIn this programming project you will design and implement an Othello playing program. If you are unfamiliar with the rules of Othello th
Duke - CPS - 271
9/11/2007What Makes a Good Prediction? Obviously: One that gives best performance in the future, but how do we pick this in advance?Choosing PredictorsCPS 271 Ron ParrRegression figures provided by Christopher Bishop and 2007 Christopher Bish
Duke - CPS - 296
Lecture notes 4: DualityVincent Conitzer1Introductionmaximize 3x1 + 2x2 subject to 4x1 + 2x2 16 x1 + 2x2 8 x1 + x2 5 x1 0; x2 0Let us again consider the linear program for our original painting problem instance:We already know that the
Duke - CPS - 140
CPS 140 - Mathematical Foundations of CS Dr. Susan Rodger Section: Introduction (Ch. 1) (handout)What will we do in CPS 140? Questions Can you write a program to determine if a string is an integer? 9998.89 8abab 789342 Can you do this if your m
Duke - CPS - 296
Lecture notes ?: Constraint and column generation, and the cutting stock problemVincent Conitzer1IntroductionSo far, we have assumed that we can explicitly write down the entire linear program. In many settings, this is not feasible: there may
Duke - CPS - 296
Lecture notes ?: Network flow problemsVincent Conitzer1IntroductionWe now consider network flow problems. Such problems have some very nice properties. Specifically, we consider the minimum cost network flow problem, also known as the transshi
Duke - CPS - 170
Lecture notes ?: Solving (mixed) integer programs using branch and boundVincent ConitzerWe now turn to solving (mixed) integer programs. There are several dierent approaches to this; most of them are based on solving various LP relaxations of the i
Duke - CPS - 296
Lecture notes ?: Solving (mixed) integer programs using branch and boundVincent ConitzerWe now turn to solving (mixed) integer programs. There are several dierent approaches to this; most of them are based on solving various LP relaxations of the i
Duke - CPS - 296
Lecture notes ?: An illustrative example: the core and network owVincent Conitzer1IntroductionWe will now consider an example from cooperative game theory (also known as coalitional game theory), the less-known sibling of noncooperative game t
Duke - CPS - 296
CPS 296.2 - Linear and integer programmingHomework 1: modeling and interpreting problems as linear and integer programs (due 2/28 before class)Please read the rules for assignments on the course web page. Contact Vince (conitzer@cs.duke.edu) with
Duke - CPS - 170
Lecture notes 1: Introduction to linear and (mixed) integer programsVincent Conitzer1An exampleWe will start with a simple example. Suppose we are in the business of selling reproductions of two dierent paintings. We can sell any number of rep
Duke - CPS - 296
Lecture notes 1: Introduction to linear and (mixed) integer programsVincent Conitzer1An exampleWe will start with a simple example. Suppose we are in the business of selling reproductions of two dierent paintings. We can sell any number of rep
Duke - CPS - 140
Section: Finite Automata Deterministic Finite Accepter (or Automata) A DFA=(Q,q0,F)input tape a a tape head b b a b head movescurrent state 0 1where Q is nite set of states is tape (input) alphabet q0 is initial state F Q is set of nal states.
Duke - CPS - 140
CompSci 140Project 1 Project Due: Thursday, Feb. 7, Midnight 30 pointsSpring 2008The company MACROBOTS has hired you to write an interpretor for a simple programming language called ROBOBABY for programming their robots. This language allows th
Duke - CPS - 124
Transformations in OpenGL Translate Rotate Scale Push Matrix Pop MatrixOpenGL Functions Transformations in OpenGL are not drawing commands. They are retained as part of the graphics state. When drawing commands are issued, the current transf
Duke - CPS - 182
CS182 2006, Reynolds and Astrachan I) Introduction (1 page) II) Motivation (3 pages) 1) Types of anonymity A) Onion routing examines routing anonymity 2) Who needs it? A) Well, criminals, naturally! B) But also: the government and the military C) Soc
Duke - CPS - 182
Executive Summary -Understanding `Everquest'- I. Situating our Issue: The Unbelievable &amp; `Everquest' This paper will use as its starting point various press releases regarding cases of murder, suicide, and the generally hard-to-believe around `Everqu
Duke - CPS - 182
!&quot;#$%&amp;'&quot;()*$+,%'(-./)'&quot;)0)1'('.02)!&quot;3'%$&quot;45&quot;.6 7)*2$/5%)8$9)0.).-5):;/'&amp;)&lt;&quot;=;/.%,&gt;'&quot;(-;')8'4*$4+;.5%)?&amp;'5&quot;&amp;5)@AB? C%$#5/$%)7/.%0&amp;-0&quot; B):0,)BDDE8'4)B 72.-$;(-)&amp;$+,%'(-./)F5%5)#'%/.)#$%4;20.5=).$)5&quot;&amp;$;%0(5)'&quot;$30.'$&quot;)G,)022$F'&quot;()&amp;$&quot;.5&quot;.H &amp;%50.$%/)
Duke - CPS - 100
Search, Backtracking,HeuristicsExhaustive Search/HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?We use binary search trees to organize data, in searching we don't need to
Duke - FEB - 100
Search, Backtracking,HeuristicsExhaustive Search/HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?We use binary search trees to organize data, in searching we don't need to
Duke - CPS - 100
APTs and structuring data/informationIs an element in an array, Where is an element in an array? DIY: use a loop Use Collections, several options public boolean contains(String[] list, Tradeoffs?}String target){ for(String s : list){ if (s.
Duke - JAN - 100
APTs and structuring data/informationIs an element in an array, Where is an element in an array? DIY: use a loop Use Collections, several options public boolean contains(String[] list, Tradeoffs?}String target){ for(String s : list){ if (s.
Duke - CPS - 100
Search, Backtracking,HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?How does Mapquest/Googlemap find routes from one place to another? Shortest path algorithms Longest
Duke - FEB - 100
Search, Backtracking,HeuristicsHow do you find a needle in a haystack? How does a computer play chess? Why would you write that program?How does Mapquest/Googlemap find routes from one place to another? Shortest path algorithms Longest
Duke - CPS - 214
INTERNATIONAL STANDARDISO/IEC 10589Second edition 2002-11-15Information technology Telecommunications and information exchange between systems Intermediate System to Intermediate System intra-domain routeing information exchange protocol for u
Duke - CPS - 049
Homework 1 solutionsFebruary 9, 2007Question 1 1. Because anchor texts tend to have more accurate descriptions of web pages they point to than the actual web pages, search quality can be improved. 2. Anchor texts help search non-text information as
Duke - CPS - 049
Duke - CPS - 210
Things Change Myth that placement is irrelevant View that OS is concerned only with the main-secondary levels of memory hierarchy New architectures / new views of the memory hierarchy Scale - larger address spaces You are Workload assumptions he
Duke - CPS - 271
Where We Stand Markov Decision ProcessesCPS 271 Ron Parr Search and planning for deterministic domains Efficient manipulation of probability distributions Decision Theory Act to maximize expected utility How do we do this? Markov Decision Pro