Unit 6: Amortized Analysis

Size: px
Start display at page:

Download "Unit 6: Amortized Analysis"

Transcription

1 : Amortized Analysis Course contents: Aggregate method Accounting method Potential method Reading: Chapter 17 Y.-W. Chang 1 Amortized Analysis Why Amortized Analysis? Find a tight bound of a sequence of data structure operations. No probability involved, guarantees the average performance of each operation in the worst case. Three popular methods Aggregate method Accounting method Potential method Y.-W. Chang 2 1

2 Methods for Amortized Analysis Aggregate method n operations take T(n) time. Average cost of an operation is T(n)/n time. Accounting method Charge each operation an amortized cost. Store the amount not used in bank. Use the stored amount for later operations. Must guarantee nonnegative balance!! Potential method View stored amount as potential energy. Y.-W. Chang 3 Aggregate method: MULTIPOP n operations take T(n) time average cost of an operation is T(n)/n time. Consider a sequence of n PUSH, POP, and MULTIPOP operations on an initially empty stack. Worst-case analysis: a MULTIPOP operation takes O(n). Aggregate method: Any sequence of n PUSH, POP, MULTIPOP costs at most O(n) time (why?) amortized cost of an operation: O(n)/n=O(1). MULTIPOP(S, k) 1.while not Stack-Empty(S) and k > 0 2. Pop(S); 3. k k-1; Y.-W. Chang 4 2

3 Incrementing a Binary Counter Increment an initially zero k-bit binary counter. Increment(A) 1. i = 0 2. while i < length[a] and A[I] == 1 3. A[i] = 0 4. i = i if i < length[a] 6. A[i] = 1 Y.-W. Chang 5 Aggregate method: Incrementing a Binary Counter Worst case: an INCREMENT operation takes O(k) time. Amortized cost: O(1) time. A[0], A[1], A[2], : flips each time, every other time, every fourth time,... that INCREMENT is called. lg n n # Flips = i0 i < 2n Amortized Cost = O(n)/n = O(1). 2 Y.-W. Chang 6 3

4 Accounting method Stack operations (s: stack size): For any sequence of n operations, total actual cost total amortized cost = O(n). Incrementing a binary counter Charge an amortized cost of $2 to set a bit to 1. 1 actual cost 1 credit Don't charge anything to reset a bit to 0 (-$1 from credit). For n increment operations, total credit = # of 1's in the counter 0, Total actual cost total amortized cost = O(n) Y.-W. Chang 7 The Potential Method View the prepaid work as potential that can be released to pay for future operations. Potential is associated with the whole data structure, not with specific items in the data structure. The potential method: D 0 : initial data structure D i : data structure after applying the i-th operation to D i-1 c i : actual cost of the i-th operation Define the potential function : D i R. c ˆi Amortized cost, = c i + (D i ) - (D i-1 ). Pick (D n ) (D 0 ) to make i1 i i1 Often define (D 0 ) = 0 and then show that (D i ) 0, i. n cˆ n c i Y.-W. Chang 8 4

5 The Potential Method: Stack Operations Amortized cost of each operation = O(1). (D) = # of objects in the stack D; (D 0 )=0, (D i ) 0. c c PUSH: = c i + (D i ) - (D i-1 ) = 1 + (s+1) - s = 2. ˆi POP: ˆi = c i + (D i ) - (D i-1 ) = 1 + (-1) = 0. MULTIPOP(S, k): k' = min(k, s) objects are popped off. = c i + (D i ) - (D i-1 ) = k' - k' = 0. Y.-W. Chang 9 Potential Method: Incrementing a Binary Counter Amortized cost of each operation = O(1). (D)= # of 1's in the counter D; let b i = (D i ) 0. Suppose the i-th increment operation resets t i bits. c i t i + 1 b i b i-1 - t i +1. c Amortized cost ˆi = c i + (D i ) - (D i-1 ) (t i + 1) - t i + 1 = 2. For b 0 k, let n = (k). c i = 5, t i = 4 b i-1 = 4, b i = 1 Y.-W. Chang 10 5

6 Dynamic Table Expansion Insertion only for the time being. Goal: Try to make table as small as possible. Idea: Allocate more memory when needed 1. Initialize table size m = Insert elements until the # of elements > m. 3. Generate a new table of size 2m. 4. Copy old elements into a new table. 5. Goto Step 2. Actual costs: c i = ith insertion. One Insertion can be costly, but in total? Worst-case cost of an insertion = O(n) total time for n insertions =O(n 2 ). Not tight!! Y.-W. Chang 11 Expansion: Aggregate and Accounting Analyses Aggregate analysis: amortized cost of an operation < 3. Accounting analysis: amortized cost of an operation < 3. Charge each operation $3 (amortized cost): $1 for immediate insertion and store $2. When table doubles, $1 for a re-inserting item and $1 for re-inserting another old item. Total runtime = # of dollars spent # of dollars entered table = 3n. $2 $2 $2 $0 $1 $1 $2 $2 $0 $1 $2 $0 $0 $0 $1 Y.-W. Chang 12 6

7 Expansion: Potential Analyses num[t]: # of elements in T; size[t]: size of the table T. (T)= 2 num[t] - size[t] Right before expansion: (T) = num[t]. Right after expansion: (T) = 0. 0 = 0; i 0. Table is always at least half full: num[t] size[t]/2 (T) 0. If i-th operation does not trigger an expansion (size i = size i-1 ): = c i + i - i-1 = 1 + (2 num i -size i ) - (2 num i-1 -size i-1 ) = 1 + (2 num i -size i ) - (2 (num i -1)-size i ) = 3. If i-th operation triggers an expansion (size i /2 = size i-1 = num i -1): = c i + i - i-1 = num i + (2 num i -size i ) - (2 num i-1 -size i-1 ) = num i + (2 num i -(2 num i -2))-(2(num i -1)-(num i -1)) = 3. Y.-W. Chang 13 Effect of Expansion (T)= 2 num[t] - size[t] Right before expansion: (T) = num[t]. Right after expansion: (T) = 0. 0 = 0; i 0. Table is always at least half full: num[t] size[t]/2 (T) 0. Y.-W. Chang 14 7

8 Expansion and Contraction: Accounting Analysis Bad idea: Double the table when overflow (as before), halve it when table < full /2. Cause thrashing when repeatedly halve and double it if repeatedly insert and delete 2 items. n = 2 k : insert n/2 items and then Insert/Delete I D D I I D D amortized cost of an operation = (n). Better idea: Double the table when overflow and halve it when table < full /4. Accounting analysis Charge $3 for each insertion (as before). Charge $2 for deletion: Store extra $1 in emptied slot; use later to pay to copy remaining items to a new table while shrinking the table. Assume we halve the table when size <= 1/4 Y.-W. Chang 15 Potential Analysis: Expansion and Contraction Load factor: (T) = num[t]/size[t] if num[t] > 0; (T) = 1 if num [T] = 0. Define the potential function (T): num 0 = 0, size 0 = 0, 0 = 1, 0 = 0, i 0. = 1 (T) = num[t]: sufficient potential for expansion. = 1/2 (T) = 0. = 1/4 (T) = num[t]: sufficient potential for contraction. Y.-W. Chang 16 8

9 Potential Analysis: Insertion i-th operation is an insertion: num i = num i i-1 1/2: 3 (as before) i-1 < 1/2, i < 1/2: = c i + i - i-1 = 1 + (size i /2 - num i ) - (size i-1 /2 - num i-1 ) = 1 + (size i /2 - num i ) - (size i /2 - (num i -1)) = 0. i-1 < 1/2, i 1/2: = c i + i - i-1 = 1 + (2 num i - size i ) - (size i-1 /2 - num i-1 ) = 1 + (2 (num i-1 + 1) - size i-1 ) - (size i-1 /2 - num i-1 ) = 3 num i-1-3size i-1 /2 + 3 = 3 i-1 size i-1-3size i-1 /2 + 3 < 3size i-1 /2-3size i-1 /2 + 3 = 3. Y.-W. Chang 17 Potential Analysis: Deletion i-th operation is a deletion: num i = num i-1-1 i-1 < 1/2, i 1/4: no contraction size i =size i-1 = c i + i - i-1 = 1 + (size i /2 - num i ) - (size i-1 /2 - num i-1 ) = 1 + (size i /2 - num i ) - (size i /2 - (num i + 1)) = 2. i-1 < 1/2, i < 1/4: with contraction size i /2 =size i-1 /4 = num i + 1 = c i + i - i-1 = (num i + 1) + (size i /2 - num i ) - (size i-1 /2 - num i-1 ) = (num i + 1) + ((num i + 1) - num i ) ((2num i + 2) - (num i + 1)) = 1. i-1 1/2 : c some constant. ˆi Y.-W. Chang 18 9

10 Appendix: B*-tree Packing Revisited x-coordinates can be determined by the tree structure. Left child: the lowest, adjacent block on the right (x j = x i + w i ). Right child: the first block above, with the same x-coordinate (x j = x i ). y-coordinates? b 5 b 6 n 0 b 1 b 3 b 2 b 4 b 10 n 7 n 1 x 1 =x 0 n 8 n 2 n 5 b 0 b 9 b 8 b 11 n 11 n 9 n 3 n 6 (x 0,y 0 ) b 7 x 7 =x 0 +w 0 n 10 n 4 w 0 Y.-W. Chang 19 Computing y-coordinates Contour: Use a doubly linked list to record the current max y-coordinate for each x-range With the B*-tree topology and block width, the y-coordinate is the max y value within the x-ranges Amortized O(1) time for computing a y-coordinate (i.e., linear time for all blocks) n 3 contour p p B*-tree topology b b 3 1 b 4 b 0 b 10 b 9 b 8 b 11 b 7 Y.-W. Chang 20 10

CS473-Algorithms I. Lecture 12. Amortized Analysis. Cevdet Aykanat - Bilkent University Computer Engineering Department

CS473-Algorithms I. Lecture 12. Amortized Analysis. Cevdet Aykanat - Bilkent University Computer Engineering Department CS473-Algorithms I Lecture 12 Amortized Analysis 1 Amortized Analysis Key point: The time required to perform a sequence of data structure operations is averaged over all operations performed Amortized

More information

COMP251: Amortized Analysis

COMP251: Amortized Analysis COMP251: Amortized Analysis Jérôme Waldispühl School of Computer Science McGill University Based on (Cormen et al., 2009) T n = 2 % T n 5 + n( What is the height of the recursion tree? log ( n log, n log

More information

CMSC 441: Design & Analysis of Algorithms

CMSC 441: Design & Analysis of Algorithms CMSC 441: Design & Analysis of Algorithms Hillol Kargupta http://www.cs.umbc.edu/~hillol/ hillol@cs.umbc.edu Today s Topics Amortized analysis April 19, 2011 CMSC 641 2 Amortized Analysis Aggregate Method

More information

Lecture 7. Analysis of algorithms: Amortized Analysis. January Lecture 7

Lecture 7. Analysis of algorithms: Amortized Analysis. January Lecture 7 Analysis of algorithms: Amortized Analysis January 2014 What is amortized analysis? Amortized analysis: set of techniques (Aggregate method, Accounting method, Potential method) for proving upper (worst-case)

More information

CS4311 Design and Analysis of Algorithms. Lecture 14: Amortized Analysis I

CS4311 Design and Analysis of Algorithms. Lecture 14: Amortized Analysis I CS43 Design and Analysis of Algorithms Lecture 4: Amortized Analysis I About this lecture Given a data structure, amortized analysis studies in a sequence of operations, the average time to perform an

More information

About this lecture. Three Methods for the Same Purpose (1) Aggregate Method (2) Accounting Method (3) Potential Method.

About this lecture. Three Methods for the Same Purpose (1) Aggregate Method (2) Accounting Method (3) Potential Method. About this lecture Given a data structure, amortized analysis studies in a sequence of operations, the average time to perform an operation Introduce amortized cost of an operation Three Methods for the

More information

Splay Trees. Splay Trees - 1

Splay Trees. Splay Trees - 1 Splay Trees In balanced tree schemes, explicit rules are followed to ensure balance. In splay trees, there are no such rules. Search, insert, and delete operations are like in binary search trees, except

More information

Outline for this Week

Outline for this Week Binomial Heaps Outline for this Week Binomial Heaps (Today) A simple, fexible, and versatile priority queue. Lazy Binomial Heaps (Today) A powerful building block for designing advanced data structures.

More information

Outline for this Week

Outline for this Week Binomial Heaps Outline for this Week Binomial Heaps (Today) A simple, flexible, and versatile priority queue. Lazy Binomial Heaps (Today) A powerful building block for designing advanced data structures.

More information

3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k

3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k //1 Adapted from: Kevin Wayne B k B k B k : a binomial tree with the addition of a left child with another binomial tree Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N( ) = 2 k B 1 B 2 B

More information

1 Solutions to Tute09

1 Solutions to Tute09 s to Tute0 Questions 4. - 4. are straight forward. Q. 4.4 Show that in a binary tree of N nodes, there are N + NULL pointers. Every node has outgoing pointers. Therefore there are N pointers. Each node,

More information

Fibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt..

Fibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt.. Fibonacci Heaps You You can can submit submit Problem Problem Set Set 3 in in the the box box up up front. front. Outline for Today Review from Last Time Quick refresher on binomial heaps and lazy binomial

More information

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class Homework #4 CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class o Grades depend on neatness and clarity. o Write your answers with enough detail about your approach and concepts

More information

> asympt( ln( n! ), n ); n 360n n

> asympt( ln( n! ), n ); n 360n n 8.4 Heap Sort (heapsort) We will now look at our first (n ln(n)) algorithm: heap sort. It will use a data structure that we have already seen: a binary heap. 8.4.1 Strategy and Run-time Analysis Given

More information

Max Registers, Counters and Monotone Circuits

Max Registers, Counters and Monotone Circuits James Aspnes 1 Hagit Attiya 2 Keren Censor 2 1 Yale 2 Technion Counters Model Collects Our goal: build a cheap counter for an asynchronous shared-memory system. Two operations: increment and read. Read

More information

Priority Queues 9/10. Binary heaps Leftist heaps Binomial heaps Fibonacci heaps

Priority Queues 9/10. Binary heaps Leftist heaps Binomial heaps Fibonacci heaps Priority Queues 9/10 Binary heaps Leftist heaps Binomial heaps Fibonacci heaps Priority queues are important in, among other things, operating systems (process control in multitasking systems), search

More information

Basic Data Structures. Figure 8.1 Lists, stacks, and queues. Terminology for Stacks. Terminology for Lists. Chapter 8: Data Abstractions

Basic Data Structures. Figure 8.1 Lists, stacks, and queues. Terminology for Stacks. Terminology for Lists. Chapter 8: Data Abstractions Chapter 8: Data Abstractions Computer Science: An Overview Tenth Edition by J. Glenn Brookshear Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing Data Structures 8.3 A Short

More information

COSC160: Data Structures Binary Trees. Jeremy Bolton, PhD Assistant Teaching Professor

COSC160: Data Structures Binary Trees. Jeremy Bolton, PhD Assistant Teaching Professor COSC160: Data Structures Binary Trees Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Binary Trees I. Implementations I. Memory Management II. Binary Search Tree I. Operations Binary Trees A

More information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶

Design and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶 Design and Analysis of Algorithms 演算法設計與分析 Lecture 8 November 6, 206 洪國寶 Outline Review Amortized analysis Advanced data structures Binary heaps Binomial heaps Fibonacci heaps Data structures for disjoint

More information

Sublinear Time Algorithms Oct 19, Lecture 1

Sublinear Time Algorithms Oct 19, Lecture 1 0368.416701 Sublinear Time Algorithms Oct 19, 2009 Lecturer: Ronitt Rubinfeld Lecture 1 Scribe: Daniel Shahaf 1 Sublinear-time algorithms: motivation Twenty years ago, there was practically no investigation

More information

Data Structures. Binomial Heaps Fibonacci Heaps. Haim Kaplan & Uri Zwick December 2013

Data Structures. Binomial Heaps Fibonacci Heaps. Haim Kaplan & Uri Zwick December 2013 Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick December 13 1 Heaps / Priority queues Binary Heaps Binomial Heaps Lazy Binomial Heaps Fibonacci Heaps Insert Find-min Delete-min Decrease-key

More information

Lecture 8 Feb 16, 2017

Lecture 8 Feb 16, 2017 CS 4: Advanced Algorithms Spring 017 Prof. Jelani Nelson Lecture 8 Feb 16, 017 Scribe: Tiffany 1 Overview In the last lecture we covered the properties of splay trees, including amortized O(log n) time

More information

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay Lecture - 15 Adaptive Huffman Coding Part I Huffman code are optimal for a

More information

CSE 417 Dynamic Programming (pt 2) Look at the Last Element

CSE 417 Dynamic Programming (pt 2) Look at the Last Element CSE 417 Dynamic Programming (pt 2) Look at the Last Element Reminders > HW4 is due on Friday start early! if you run into problems loading data (date parsing), try running java with Duser.country=US Duser.language=en

More information

Lecture 9 Feb. 21, 2017

Lecture 9 Feb. 21, 2017 CS 224: Advanced Algorithms Spring 2017 Lecture 9 Feb. 21, 2017 Prof. Jelani Nelson Scribe: Gavin McDowell 1 Overview Today: office hours 5-7, not 4-6. We re continuing with online algorithms. In this

More information

Recall: Data Flow Analysis. Data Flow Analysis Recall: Data Flow Equations. Forward Data Flow, Again

Recall: Data Flow Analysis. Data Flow Analysis Recall: Data Flow Equations. Forward Data Flow, Again Data Flow Analysis 15-745 3/24/09 Recall: Data Flow Analysis A framework for proving facts about program Reasons about lots of little facts Little or no interaction between facts Works best on properties

More information

Design and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶

Design and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶 Design and Analysis of Algorithms 演算法設計與分析 Lecture 9 November 19, 2014 洪國寶 1 Outline Advanced data structures Binary heaps(review) Binomial heaps Fibonacci heaps Data structures for disjoint sets 2 Mergeable

More information

Heaps. Heap/Priority queue. Binomial heaps: Advanced Algorithmics (4AP) Heaps Binary heap. Binomial heap. Jaak Vilo 2009 Spring

Heaps. Heap/Priority queue. Binomial heaps: Advanced Algorithmics (4AP) Heaps Binary heap. Binomial heap. Jaak Vilo 2009 Spring .0.00 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Advanced Algorithmics (4AP) Heaps Jaak Vilo 00 Spring Binary heap http://en.wikipedia.org/wiki/binary_heap Binomial heap http://en.wikipedia.org/wiki/binomial_heap

More information

UNIT VI TREES. Marks - 14

UNIT VI TREES. Marks - 14 UNIT VI TREES Marks - 14 SYLLABUS 6.1 Non-linear data structures 6.2 Binary trees : Complete Binary Tree, Basic Terms: level number, degree, in-degree and out-degree, leaf node, directed edge, path, depth,

More information

Heaps

Heaps AdvancedAlgorithmics (4AP) Heaps Jaak Vilo 2009 Spring Jaak Vilo MTAT.03.190 Text Algorithms 1 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Binary heap http://en.wikipedia.org/wiki/binary_heap

More information

Binary and Binomial Heaps. Disclaimer: these slides were adapted from the ones by Kevin Wayne

Binary and Binomial Heaps. Disclaimer: these slides were adapted from the ones by Kevin Wayne Binary and Binomial Heaps Disclaimer: these slides were adapted from the ones by Kevin Wayne Priority Queues Supports the following operations. Insert element x. Return min element. Return and delete minimum

More information

2. This algorithm does not solve the problem of finding a maximum cardinality set of non-overlapping intervals. Consider the following intervals:

2. This algorithm does not solve the problem of finding a maximum cardinality set of non-overlapping intervals. Consider the following intervals: 1. No solution. 2. This algorithm does not solve the problem of finding a maximum cardinality set of non-overlapping intervals. Consider the following intervals: E A B C D Obviously, the optimal solution

More information

Design and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶

Design and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶 Design and Analysis of Algorithms 演算法設計與分析 Lecture 9 November 20, 2013 洪國寶 1 Outline Advanced data structures Binary heaps (review) Binomial heaps Fibonacci heaps Dt Data structures t for disjoint dijitsets

More information

It is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission

It is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission It is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission -The code can be described in terms of a binary tree -0 corresponds to

More information

Outline for Today. Quick refresher on binomial heaps and lazy binomial heaps. An important operation in many graph algorithms.

Outline for Today. Quick refresher on binomial heaps and lazy binomial heaps. An important operation in many graph algorithms. Fibonacci Heaps Outline for Today Review from Last Time Quick refresher on binomial heaps and lazy binomial heaps. The Need for decrease-key An important operation in many graph algorithms. Fibonacci Heaps

More information

2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes

2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes ¼ À ÈÌ Ê ½¾ ÈÊÇ Ä ÅË ½µ ½¾º¾¹½ ¾µ ½¾º¾¹ µ ½¾º¾¹ µ ½¾º¾¹ µ ½¾º ¹ µ ½¾º ¹ µ ½¾º ¹¾ µ ½¾º ¹ µ ½¾¹¾ ½¼µ ½¾¹ ½ (1) CLR 12.2-1 Based on the structure of the binary tree, and the procedure of Tree-Search, any

More information

6.854J / J Advanced Algorithms Fall 2008

6.854J / J Advanced Algorithms Fall 2008 MIT OpenCourseWare http://ocw.mit.edu 6.854J / 18.415J Advanced Algorithms Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 18.415/6.854 Advanced

More information

Priority queue. Advanced Algorithmics (6EAP) Binary heap. Heap/Priority queue. Binomial heaps: Merge two heaps.

Priority queue. Advanced Algorithmics (6EAP) Binary heap. Heap/Priority queue. Binomial heaps: Merge two heaps. Priority queue Advanced Algorithmics (EAP) MTAT.03.38 Heaps Jaak Vilo 0 Spring Insert Q, x Retrieve x from Q s.t. x.value is min (or max) Sorted linked list: O(n) to insert x into right place O() access-

More information

Advanced Algorithmics (4AP) Heaps

Advanced Algorithmics (4AP) Heaps Advanced Algorithmics (4AP) Heaps Jaak Vilo 2009 Spring Jaak Vilo MTAT.03.190 Text Algorithms 1 Heaps http://en.wikipedia.org/wiki/category:heaps_(structure) Binary heap http://en.wikipedia.org/wiki/binary

More information

Priority Queues. Fibonacci Heap

Priority Queues. Fibonacci Heap ibonacci Heap hans to Sartaj Sahni for the original version of the slides Operation mae-heap insert find-min delete-min union decrease-ey delete Priority Queues Lined List Binary Binomial Heaps ibonacci

More information

Chapter 16. Binary Search Trees (BSTs)

Chapter 16. Binary Search Trees (BSTs) Chapter 16 Binary Search Trees (BSTs) Search trees are tree-based data structures that can be used to store and search for items that satisfy a total order. There are many types of search trees designed

More information

On the Optimality of a Family of Binary Trees Techical Report TR

On the Optimality of a Family of Binary Trees Techical Report TR On the Optimality of a Family of Binary Trees Techical Report TR-011101-1 Dana Vrajitoru and William Knight Indiana University South Bend Department of Computer and Information Sciences Abstract In this

More information

The potential function φ for the amortized analysis of an operation on Fibonacci heap at time (iteration) i is given by the following equation:

The potential function φ for the amortized analysis of an operation on Fibonacci heap at time (iteration) i is given by the following equation: Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 01 Advanced Data Structures

More information

Decision Trees: Booths

Decision Trees: Booths DECISION ANALYSIS Decision Trees: Booths Terri Donovan recorded: January, 2010 Hi. Tony has given you a challenge of setting up a spreadsheet, so you can really understand whether it s wiser to play in

More information

SET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2)

SET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2) SET 1C Binary Trees 1. Construct a binary tree whose preorder traversal is K L N M P R Q S T and inorder traversal is N L K P R M S Q T 2. (i) Define the height of a binary tree or subtree and also define

More information

COMP Analysis of Algorithms & Data Structures

COMP Analysis of Algorithms & Data Structures COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Binomial Heaps CLRS 6.1, 6.2, 6.3 University of Manitoba Priority queues A priority queue is an abstract data type formed by a set S of

More information

CSCE 750, Fall 2009 Quizzes with Answers

CSCE 750, Fall 2009 Quizzes with Answers CSCE 750, Fall 009 Quizzes with Answers Stephen A. Fenner September 4, 011 1. Give an exact closed form for Simplify your answer as much as possible. k 3 k+1. We reduce the expression to a form we ve already

More information

PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES

PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES WIKTOR JAKUBIUK, KESHAV PURANMALKA 1. Introduction Dijkstra s algorithm solves the single-sourced shorest path problem on a

More information

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1.

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1. AVL Trees In order to have a worst case running time for insert and delete operations to be O(log n), we must make it impossible for there to be a very long path in the binary search tree. The first balanced

More information

Administration CSE 326: Data Structures

Administration CSE 326: Data Structures Administration CSE : Data Structures Binomial Queues Neva Cherniavsky Summer Released today: Project, phase B Due today: Homework Released today: Homework I have office hours tomorrow // Binomial Queues

More information

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES CSE 100: TREAPS AND RANDOMIZED SEARCH TREES Midterm Review Practice Midterm covered during Sunday discussion Today Run time analysis of building the Huffman tree AVL rotations and treaps Huffman s algorithm

More information

Issues. Senate (Total = 100) Senate Group 1 Y Y N N Y 32 Senate Group 2 Y Y D N D 16 Senate Group 3 N N Y Y Y 30 Senate Group 4 D Y N D Y 22

Issues. Senate (Total = 100) Senate Group 1 Y Y N N Y 32 Senate Group 2 Y Y D N D 16 Senate Group 3 N N Y Y Y 30 Senate Group 4 D Y N D Y 22 1. Every year, the United States Congress must approve a budget for the country. In order to be approved, the budget must get a majority of the votes in the Senate, a majority of votes in the House, and

More information

Lecture 5: Tuesday, January 27, Peterson s Algorithm satisfies the No Starvation property (Theorem 1)

Lecture 5: Tuesday, January 27, Peterson s Algorithm satisfies the No Starvation property (Theorem 1) Com S 611 Spring Semester 2015 Advanced Topics on Distributed and Concurrent Algorithms Lecture 5: Tuesday, January 27, 2015 Instructor: Soma Chaudhuri Scribe: Nik Kinkel 1 Introduction This lecture covers

More information

Fibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04

Fibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04 Fibonacci Heaps CLRS: Chapter 20 Last Revision: 21/09/04 1 Binary heap Binomial heap Fibonacci heap Procedure (worst-case) (worst-case) (amortized) Make-Heap Θ(1) Θ(1) Θ(1) Insert Θ(lg n) O(lg n) Θ(1)

More information

Mutual Fund & Stock Basis Keeper

Mutual Fund & Stock Basis Keeper A Guide To Mutual Fund & Stock Basis Keeper By Denver Tax Software, Inc. Copyright 1995-2006 Denver Tax Software, Inc. Denver Tax Software, Inc. P.O. Box 5308 Denver, CO 80217-5308 Telephone (voice): Toll-Free:

More information

Node betweenness centrality: the definition.

Node betweenness centrality: the definition. Brandes algorithm These notes supplement the notes and slides for Task 11. They do not add any new material, but may be helpful in understanding the Brandes algorithm for calculating node betweenness centrality.

More information

The following content is provided under a Creative Commons license. Your support

The following content is provided under a Creative Commons license. Your support MITOCW Recitation 6 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make

More information

Lecture 3. Understanding the optimizer sensitivity report 4 Shadow (or dual) prices 4 Right hand side ranges 4 Objective coefficient ranges

Lecture 3. Understanding the optimizer sensitivity report 4 Shadow (or dual) prices 4 Right hand side ranges 4 Objective coefficient ranges Decision Models Lecture 3 1 Lecture 3 Understanding the optimizer sensitivity report 4 Shadow (or dual) prices 4 Right hand side ranges 4 Objective coefficient ranges Bidding Problems Summary and Preparation

More information

Empirical and Average Case Analysis

Empirical and Average Case Analysis Empirical and Average Case Analysis l We have discussed theoretical analysis of algorithms in a number of ways Worst case big O complexities Recurrence relations l What we often want to know is what will

More information

4 Martingales in Discrete-Time

4 Martingales in Discrete-Time 4 Martingales in Discrete-Time Suppose that (Ω, F, P is a probability space. Definition 4.1. A sequence F = {F n, n = 0, 1,...} is called a filtration if each F n is a sub-σ-algebra of F, and F n F n+1

More information

Binary Tree Applications

Binary Tree Applications Binary Tree Applications Lecture 32 Section 19.2 Robb T. Koether Hampden-Sydney College Wed, Apr 17, 2013 Robb T. Koether (Hampden-Sydney College) Binary Tree Applications Wed, Apr 17, 2013 1 / 46 1 Expression

More information

Econ 101A Final Exam We May 9, 2012.

Econ 101A Final Exam We May 9, 2012. Econ 101A Final Exam We May 9, 2012. You have 3 hours to answer the questions in the final exam. We will collect the exams at 2.30 sharp. Show your work, and good luck! Problem 1. Utility Maximization.

More information

Decidability and Recursive Languages

Decidability and Recursive Languages Decidability and Recursive Languages Let L (Σ { }) be a language, i.e., a set of strings of symbols with a finite length. For example, {0, 01, 10, 210, 1010,...}. Let M be a TM such that for any string

More information

CIS 540 Fall 2009 Homework 2 Solutions

CIS 540 Fall 2009 Homework 2 Solutions CIS 54 Fall 29 Homework 2 Solutions October 25, 29 Problem (a) We can choose a simple ordering for the variables: < x 2 < x 3 < x 4. The resulting OBDD is given in Fig.. x 2 x 2 x 3 x 4 x 3 Figure : OBDD

More information

G5212: Game Theory. Mark Dean. Spring 2017

G5212: Game Theory. Mark Dean. Spring 2017 G5212: Game Theory Mark Dean Spring 2017 Bargaining We will now apply the concept of SPNE to bargaining A bit of background Bargaining is hugely interesting but complicated to model It turns out that the

More information

7. EURORAI-Congress in London on October 4, 2010 "Challenges of the economic crisis for administration and control in Upper Austria"

7. EURORAI-Congress in London on October 4, 2010 Challenges of the economic crisis for administration and control in Upper Austria 7. EURORAI-Congress in London on October 4, 2010 "Challenges of the economic crisis for administration and control in Upper Austria" Elke Anast Martin Mühlbachler I T a b l e of c o n t e n t s Upper Austria

More information

Money Math for Teens. Before You Choose a Credit Card

Money Math for Teens. Before You Choose a Credit Card Money Math for Teens Before You Choose a Credit Card This Money Math for Teens lesson is part of a series created by Generation Money, a multimedia financial literacy initiative of the FINRA Investor Education

More information

Borsa Italiana Trading Station. Authorization Service Guide. Version 7.3

Borsa Italiana Trading Station. Authorization Service Guide. Version 7.3 Borsa Italiana Trading Station Authorization Service Guide Version 7.3 BIT Trading Station 1 Revision History Date Version Description 31/12/2003 1.0 First release 31/07/2005 2.2 (Instrument) Group hierarchy

More information

Creditors / Suppliers

Creditors / Suppliers Arch User Guide ver. 25 Classification: Document History Date Version Changed By Details 2015-03-09 1.0 Karl van Niekerk Created Document 2015-07-09 1.1 Karl van Niekerk Updated Document Document Version

More information

CEC login. Student Details Name SOLUTIONS

CEC login. Student Details Name SOLUTIONS Student Details Name SOLUTIONS CEC login Instructions You have roughly 1 minute per point, so schedule your time accordingly. There is only one correct answer per question. Good luck! Question 1. Searching

More information

f x f x f x f x x 5 3 y-intercept: y-intercept: y-intercept: y-intercept: y-intercept of a linear function written in function notation

f x f x f x f x x 5 3 y-intercept: y-intercept: y-intercept: y-intercept: y-intercept of a linear function written in function notation Questions/ Main Ideas: Algebra Notes TOPIC: Function Translations and y-intercepts Name: Period: Date: What is the y-intercept of a graph? The four s given below are written in notation. For each one,

More information

Monte-Carlo Planning: Introduction and Bandit Basics. Alan Fern

Monte-Carlo Planning: Introduction and Bandit Basics. Alan Fern Monte-Carlo Planning: Introduction and Bandit Basics Alan Fern 1 Large Worlds We have considered basic model-based planning algorithms Model-based planning: assumes MDP model is available Methods we learned

More information

9.7 Binomial Queues. This excerpt made available by permission of Robert Sedgewick, and of Pearson Education, Inc.

9.7 Binomial Queues. This excerpt made available by permission of Robert Sedgewick, and of Pearson Education, Inc. 406 9.7 CH lgorithms, 3rd dition, in Java, arts 1-4: Fundamentals, Data tructures, orting, and earching. obert edgewick, ddison-esley 2002. his excerpt made available by permission of obert edgewick, and

More information

Successor. CS 361, Lecture 19. Tree-Successor. Outline

Successor. CS 361, Lecture 19. Tree-Successor. Outline Successor CS 361, Lecture 19 Jared Saia University of New Mexico The successor of a node x is the node that comes after x in the sorted order determined by an in-order tree walk. If all keys are distinct,

More information

Optimal Satisficing Tree Searches

Optimal Satisficing Tree Searches Optimal Satisficing Tree Searches Dan Geiger and Jeffrey A. Barnett Northrop Research and Technology Center One Research Park Palos Verdes, CA 90274 Abstract We provide an algorithm that finds optimal

More information

Space-Efficient Manifest Contracts. Michael Greenberg Princeton University POPL 2015

Space-Efficient Manifest Contracts. Michael Greenberg Princeton University POPL 2015 Space-Efficient Manifest Contracts Michael Greenberg Princeton University POPL 2015 (First-order) contracts Specifications Written in code Checked at runtime 2 (First-order) contracts Specifications Written

More information

Lecture l(x) 1. (1) x X

Lecture l(x) 1. (1) x X Lecture 14 Agenda for the lecture Kraft s inequality Shannon codes The relation H(X) L u (X) = L p (X) H(X) + 1 14.1 Kraft s inequality While the definition of prefix-free codes is intuitively clear, we

More information

1.6 Heap ordered trees

1.6 Heap ordered trees 1.6 Heap ordered trees A heap ordered tree is a tree satisfying the following condition. The key of a node is not greater than that of each child if any In a heap ordered tree, we can not implement find

More information

PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley

PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley PRIORITY QUEUES binary heaps d-ary heaps binomial heaps Fibonacci heaps Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated

More information

Linear Programming: Simplex Method

Linear Programming: Simplex Method Mathematical Modeling (STAT 420/620) Spring 2015 Lecture 10 February 19, 2015 Linear Programming: Simplex Method Lecture Plan 1. Linear Programming and Simplex Method a. Family Farm Problem b. Simplex

More information

FUNCIONAMIENTO DEL ALGORITMO DEL PCR: EUPHEMIA

FUNCIONAMIENTO DEL ALGORITMO DEL PCR: EUPHEMIA FUNCIONAMIENTO DEL ALGORITMO DEL PCR: EUPHEMIA 09-04-2013 INTRODUCTION PCR can have two functions: For Power Exchanges: Most competitive price will arise & Overall welfare increases Isolated Markets Price

More information

TEPZZ 858Z 5A_T EP A1 (19) (11) EP A1 (12) EUROPEAN PATENT APPLICATION. (43) Date of publication: Bulletin 2015/15

TEPZZ 858Z 5A_T EP A1 (19) (11) EP A1 (12) EUROPEAN PATENT APPLICATION. (43) Date of publication: Bulletin 2015/15 (19) TEPZZ 88Z A_T (11) EP 2 88 02 A1 (12) EUROPEAN PATENT APPLICATION (43) Date of publication: 08.04. Bulletin / (1) Int Cl.: G06Q /00 (12.01) (21) Application number: 13638.6 (22) Date of filing: 01..13

More information

EUPHEMIA: Description and functioning. Date: July 2016

EUPHEMIA: Description and functioning. Date: July 2016 EUPHEMIA: Description and functioning Date: July 2016 PCR users and members Markets using PCR: MRC Markets using PCR: 4MMC Markets PCR members Independent users of PCR Markets associate members of PCR

More information

Algorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps

Algorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps Priority queue data type Lecture slides by Kevin Wayne Copyright 05 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos PRIORITY QUEUES binary heaps d-ary heaps binomial heaps Fibonacci

More information

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann

Chapter 7. Registers & Register Transfers. J.J. Shann. J. J. Shann Chapter 7 Registers & Register Transfers J. J. Shann J.J. Shann Chapter Overview 7-1 Registers and Load Enable 7-2 Register Transfers 7-3 Register Transfer Operations 7-4 A Note for VHDL and Verilog Users

More information

Trading Diary Manual. Introduction

Trading Diary Manual. Introduction Trading Diary Manual Introduction Welcome, and congratulations! You ve made a wise choice by purchasing this software, and if you commit to using it regularly and consistently you will not be able but

More information

Lattice Model of System Evolution. Outline

Lattice Model of System Evolution. Outline Lattice Model of System Evolution Richard de Neufville Professor of Engineering Systems and of Civil and Environmental Engineering MIT Massachusetts Institute of Technology Lattice Model Slide 1 of 48

More information

TTIC An Introduction to the Theory of Machine Learning. The Adversarial Multi-armed Bandit Problem Avrim Blum.

TTIC An Introduction to the Theory of Machine Learning. The Adversarial Multi-armed Bandit Problem Avrim Blum. TTIC 31250 An Introduction to the Theory of Machine Learning The Adversarial Multi-armed Bandit Problem Avrim Blum Start with recap 1 Algorithm Consider the following setting Each morning, you need to

More information

Day 3 Simple vs Compound Interest.notebook April 07, Simple Interest is money paid or earned on the. The Principal is the

Day 3 Simple vs Compound Interest.notebook April 07, Simple Interest is money paid or earned on the. The Principal is the LT: I can calculate simple and compound interest. p.11 What is Simple Interest? What is Principal? Simple Interest is money paid or earned on the. The Principal is the What is the Simple Interest Formula?

More information

Finance 197. Simple One-time Interest

Finance 197. Simple One-time Interest Finance 197 Finance We have to work with money every day. While balancing your checkbook or calculating your monthly expenditures on espresso requires only arithmetic, when we start saving, planning for

More information

Finding Roots by "Closed" Methods

Finding Roots by Closed Methods Finding Roots by "Closed" Methods One general approach to finding roots is via so-called "closed" methods. Closed methods A closed method is one which starts with an interval, inside of which you know

More information

Option Pricing. Chapter Discrete Time

Option Pricing. Chapter Discrete Time Chapter 7 Option Pricing 7.1 Discrete Time In the next section we will discuss the Black Scholes formula. To prepare for that, we will consider the much simpler problem of pricing options when there are

More information

Chapter 15: Dynamic Programming

Chapter 15: Dynamic Programming Chapter 15: Dynamic Programming Dynamic programming is a general approach to making a sequence of interrelated decisions in an optimum way. While we can describe the general characteristics, the details

More information

Warm Up Finitely Repeated Games Infinitely Repeated Games Bayesian Games. Repeated Games

Warm Up Finitely Repeated Games Infinitely Repeated Games Bayesian Games. Repeated Games Repeated Games Warm up: bargaining Suppose you and your Qatz.com partner have a falling-out. You agree set up two meetings to negotiate a way to split the value of your assets, which amount to $1 million

More information

ECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2017

ECON 459 Game Theory. Lecture Notes Auctions. Luca Anderlini Spring 2017 ECON 459 Game Theory Lecture Notes Auctions Luca Anderlini Spring 2017 These notes have been used and commented on before. If you can still spot any errors or have any suggestions for improvement, please

More information

Problem Set 2: Answers

Problem Set 2: Answers Economics 623 J.R.Walker Page 1 Problem Set 2: Answers The problem set came from Michael A. Trick, Senior Associate Dean, Education and Professor Tepper School of Business, Carnegie Mellon University.

More information

TDT4255 Lecture 7: Hazards and exceptions

TDT4255 Lecture 7: Hazards and exceptions TDT4255 Lecture 7: Hazards and exceptions Donn Morrison Department of Computer Science 2 Outline Section 4.7: Data hazards: forwarding and stalling Section 4.8: Control hazards Section 4.9: Exceptions

More information

Sequences (Part 3) Supplemental Material Not Found in You Text

Sequences (Part 3) Supplemental Material Not Found in You Text Motivating Examples Math 34: Spring 2016 Sequences (Part 3) Supplemental Material Not Found in You Text Geometric Sequences will help us answer the following: An interest-free loan of $12, 000 requires

More information

A t S + b r t T B (h i + 1) (t S + t T ) C h i (t S + t T ) + t S + b t T D (h i + n) (t S + t T )

A t S + b r t T B (h i + 1) (t S + t T ) C h i (t S + t T ) + t S + b t T D (h i + n) (t S + t T ) Suppose we have a primary B+-tree index where the leaves contain search keys and RIDs, and the RIDs point to the records in a file that is ordered on the index search key. Assume that the blocks in the

More information

CS 343: Artificial Intelligence

CS 343: Artificial Intelligence CS 343: Artificial Intelligence Markov Decision Processes II Prof. Scott Niekum The University of Texas at Austin [These slides based on those of Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC

More information