Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
|
|
- Stella Shelton
- 5 years ago
- Views:
Transcription
1 Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Princeton University COS 4 Theory of Algorithms Spring 2002 Kevin Wayne
2 Priority Queues Operation mae-heap insert find- delete- union decrease-ey delete Lined List 1 1 N N 1 1 N Binary 1 log N 1 log N N log N log N Binomial 1 log N log N log N log N log N log N Heaps Fibonacci log N 1 1 log N Relaxed is-empty log N 1 1 log N amortized this time 2
3 Fibonacci Heaps Fibonacci heap history. Fredman and Tarjan (1986) Ingenious data structure and analysis. Original motivation: O(m + n log n) shortest path algorithm. also led to faster algorithms for MST, weighted bipartite matching Still ahead of its time. Fibonacci heap intuition. Similar to binomial heaps, but less structured. Decrease-ey and union run in O(1) time. "Lazy" unions. 3
4 Fibonacci Heaps: Structure Fibonacci heap. Set of -heap ordered trees mared H 4
5 Fibonacci Heaps: Implementation Implementation. Represent trees using left-child, right sibling pointers and circular, doubly lined list. can quicly splice off subtrees Roots of trees connected with circular doubly lined list. fast union Pointer to root of tree with element. fast find H 5
6 Fibonacci Heaps: Potential Function Key quantities. Degree[x] = degree of node x. Mar[x] = mar of node x (blac or gray). t(h) = # trees. m(h) = # mared nodes. Φ(H) = t(h) + 2m(H) = potential function. t(h) = 5, m(h) = 3 Φ(H) = 11 degree = H 6
7 Fibonacci Heaps: Insert Insert. Create a new singleton tree. Add to left of pointer. Update pointer. Insert H
8 Fibonacci Heaps: Insert Insert. Create a new singleton tree. Add to left of pointer. Update pointer. Insert H 8
9 Fibonacci Heaps: Insert Insert. Create a new singleton tree. Add to left of pointer. Update pointer. Running time. O(1) amortized Actual cost = O(1). Change in potential = +1. Amortized cost = O(1). Insert H 9
10 Fibonacci Heaps: Union Union. Concatenate two Fibonacci heaps. Root lists are circular, doubly lined lists H H
11 Fibonacci Heaps: Union Union. Concatenate two Fibonacci heaps. Root lists are circular, doubly lined lists. Running time. O(1) amortized Actual cost = O(1). Change in potential = 0. Amortized cost = O(1) H H
12 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree
13 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree. current
14 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
15 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree. current
16 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current 16
17 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current Merge 1 and trees. 1
18 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current Merge and 1 trees. 18
19 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current Merge and 24 trees. 19
20 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
21 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
22 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
23 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current Merge and 18 trees.
24 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
25 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree current
26 Fibonacci Heaps: Delete Min Delete. Delete and concatenate its children into root list. Consolidate trees so that no two roots have same degree Stop. 26
27 Fibonacci Heaps: Delete Min Analysis Notation. D(n) = max degree of any node in Fibonacci heap with n nodes. t(h) = # trees in heap H. Φ(H) = t(h) + 2m(H). Actual cost. O(D(n) + t(h)) O(D(n)) wor adding s children into root list and updating. at most D(n) children of node O(D(n) + t(h)) wor consolidating trees. wor is proportional to size of root list since number of roots decreases by one after each merging D(n) + t(h) - 1 root nodes at beginning of consolidation Amortized cost. O(D(n)) t(h ) D(n) + 1 since no two trees have same degree. Φ(H) D(n) t(h). 2
28 Fibonacci Heaps: Delete Min Analysis Is amortized cost of O(D(n)) good? Yes, if only Insert, Delete-, and Union operations supported. in this case, Fibonacci heap contains only binomial trees since we only merge trees of equal root degree this implies D(n) log 2 N Yes, if we support Decrease-ey in clever way. we ll show that D(n) log φ N, where φ is golden ratio φ 2 = 1 + φ φ = (1 + 5) / 2 = limiting ratio between successive Fibonacci numbers! 28
29 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 0: -heap property not violated. decrease ey of x to change heap pointer if necessary Decrease 46 to
30 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 1: parent of x is unmared. decrease ey of x to cut off lin between x and its parent mar parent add tree rooted at x to root list, updating heap pointer Decrease 45 to 15.
31 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 1: parent of x is unmared. decrease ey of x to cut off lin between x and its parent mar parent add tree rooted at x to root list, updating heap pointer Decrease 45 to
32 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 1: parent of x is unmared. decrease ey of x to cut off lin between x and its parent mar parent add tree rooted at x to root list, updating heap pointer Decrease 45 to
33 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 2: parent of x is mared. decrease ey of x to cut off lin between x and its parent p[x], and add x to root list cut off lin between p[x] and p[p[x]], add p[x] to root list! If p[p[x]] unmared, then mar it.! If p[p[x]] mared, cut off p[p[x]], unmar, and repeat Decrease to 5. 33
34 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 2: parent of x is mared. decrease ey of x to cut off lin between x and its parent p[x], and add x to root list cut off lin between p[x] and p[p[x]], add p[x] to root list! If p[p[x]] unmared, then mar it.! If p[p[x]] mared, cut off p[p[x]], unmar, and repeat parent mared Decrease to 5. 34
35 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 2: parent of x is mared. decrease ey of x to cut off lin between x and its parent p[x], and add x to root list cut off lin between p[x] and p[p[x]], add p[x] to root list! If p[p[x]] unmared, then mar it.! If p[p[x]] mared, cut off p[p[x]], unmar, and repeat parent mared 52 Decrease to 5.
36 Fibonacci Heaps: Decrease Key Decrease ey of element x to. Case 2: parent of x is mared. decrease ey of x to cut off lin between x and its parent p[x], and add x to root list cut off lin between p[x] and p[p[x]], add p[x] to root list! If p[p[x]] unmared, then mar it.! If p[p[x]] mared, cut off p[p[x]], unmar, and repeat Decrease to 5. 36
37 Fibonacci Heaps: Decrease Key Analysis Notation. t(h) = # trees in heap H. m(h) = # mared nodes in heap H. Φ(H) = t(h) + 2m(H). Actual cost. O(c) O(1) time for decrease ey. O(1) time for each of c cascading cuts, plus reinserting in root list. Amortized cost. O(1) t(h ) = t(h) + c m(h ) m(h) - c + 2 each cascading cut unmars a node last cascading cut could potentially mar a node Φ c + 2(-c + 2) = 4 - c. 3
38 Fibonacci Heaps: Delete Delete node x. Decrease ey of x to -. Delete element in heap. Amortized cost. O(D(n)) O(1) for decrease-ey. O(D(n)) for delete-. D(n) = max degree of any node in Fibonacci heap. 38
39 Fibonacci Heaps: Bounding Max Degree Definition. D(N) = max degree in Fibonacci heap with N nodes. Key lemma. D(N) log φ N, where φ = (1 + 5) / 2. Corollary. Delete and Delete- tae O(log N) amortized time. Lemma. Let x be a node with degree, and let y 1,..., y denote the children of x in the order in which they were lined to x. Then: Proof. When y i is lined to x, y 1,..., y i-1 already lined to x, degree(x) = i - 1 degree(y i ) = i - 1 since we only lin nodes of equal degree Since then, y i degree has lost at most one child otherwise it would have been cut from x Thus, degree(y i ) = i - 1 or i - 2 ( y i ) 0 i 2 if if i = 1 i 1
40 Fibonacci Heaps: Bounding Max Degree Key lemma. In a Fibonacci heap with N nodes, the maximum degree of any node is at most log φ N, where φ = (1 + 5) / 2. Proof of ey lemma. For any node x, we show that size(x) φ degree(x). size(x) = # node in subtree rooted at x taing base φ logs, degree(x) log φ (size(x)) log φ N. Let s be size of tree rooted at any degree node. trivial to see that s 0 = 1, s 1 = 2 s monotonically increases with Let x* be a degree node of size s, and let y 1,..., y be children in order that they were lined to x*. Assume 2 s = = = size ( x*) size( y i= 2 i= 2 s i= 2 2 s i= 0 s deg[ y i 2 i i i ] ) 40
41 Fibonacci Facts Definition. The Fibonacci sequence is: 1, 2, 3, 5, 8, 13, 21,... Slightly nonstandard definition. F = 1 2 F -1 + F -2 if if if = 0 = 1 2 Fact F1. F φ, where φ = (1 + 5) / 2 = Fact F2. For 2, 2 F = 2 + F i i= 0 Consequence. s F φ. This implies that size(x) φ degree(x) for all nodes x. s = = = size ( x*) size( y i= 2 i= 2 s i= 2 2 s i= 0 s deg[ y i 2 i i i ] )
42 Golden Ratio Definition. The Fibonacci sequence is: 1, 2, 3, 5, 8, 13, 21,... Definition. The golden ratio φ = (1 + 5) / 2 = Divide a rectangle into a square and smaller rectangle such that the smaller rectangle has the same ratio as original one. Parthenon, Athens Greece 42
43 Fibonacci Facts 43
44 Fibonacci Numbers and Nature Pinecone Cauliflower
45 45 Fibonacci Proofs Fact F1. F φ. Proof. (by induction on ) Base cases: F 0 = 1, F 1 = 2 φ. Inductive hypotheses: F φ and F +1 φ +1 Fact F2. Proof. (by induction on ) Base cases: F 2 = 3, F 3 = 5 Inductive hypotheses: + = = , For i F F i ) ( ) ( = = + = + + = F F F ϕ ϕ ϕ ϕ ϕ ϕ ϕ φ 2 = φ = = i F F i + = + + = + = = = i i i F F F F F F
46 On Complicated Algorithms "Once you succeed in writing the programs for [these] complicated algorithms, they usually run extremely fast. The computer doesn t need to understand the algorithm, its tas is only to run the programs." R. E. Tarjan 46
Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn
Chapter 5 Data Structures Algorithm Theory WS 2017/18 Fabian Kuhn Priority Queue / Heap Stores (key,data) pairs (like dictionary) But, different set of operations: Initialize-Heap: creates new empty heap
More informationFIBONACCI HEAPS. preliminaries insert extract the minimum decrease key bounding the rank meld and delete. Copyright 2013 Kevin Wayne
FIBONACCI HEAPS preliminaries insert extract the minimum decrease key bounding the rank meld and delete Copyright 2013 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on Sep
More informationAnalysis of Algorithms. Outline 1 Introduction Basic Definitions Ordered Trees. Fibonacci Heaps. Andres Mendez-Vazquez. October 29, Notes.
Analysis of Algorithms Fibonacci Heaps Andres Mendez-Vazquez October 29, 2015 1 / 119 Outline 1 Introduction Basic Definitions Ordered Trees 2 Binomial Trees Example 3 Fibonacci Heap Operations Fibonacci
More information8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm
8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements
More informationMon Tue Wed Thurs Fri
In lieu of recitations 320 Office Hours Mon Tue Wed Thurs Fri 8 Cole 9 Dr. Georg Dr. Georg 10 Dr. Georg/ Jim 11 Ali Jim 12 Cole Ali 1 Cole/ Shannon Ali 2 Shannon 3 Dr. Georg Dr. Georg Jim 4 Upcoming Check
More informationAlgorithms Theory. 08 Fibonacci Heaps
Algorithms Theory 08 Fibonacci Heaps Prof. Dr. S. Albers Priority queues: operations Priority queue Q Operations: Q.initialize(): initializes an empty queue Q Q.isEmpty(): returns true iff Q is empty Q.insert(e):
More informationFibonacci (Min-)Heap. (I draw dashed lines in place of of circular lists.) 1 / 17
Fibonacci (Min-)Heap A forest of heap-order trees (parent priority child priority). Roots in circular doubly-linked list. Pointer to minimum-priority root. Siblings in circular doubly-linked list; parent
More information25. Minimum Spanning Trees
695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,
More information25. Minimum Spanning Trees
Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci
More informationL feb abhi shelat
L10 661 feb 17 2009 abhi shelat General-MST-Strategy(G =(V, E)) 1 A 2 repeat V 1 times: 3 Pick a cut (S, V S) that respects A 4 Let e be min-weight edge over cut (S, V S) 5 A A {e} prim General-MST-Strategy(G
More information2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures
2-INF-237 Vybrané partie z dátových štruktúr 2-INF-237 Selected Topics in Data Structures Instructor: Broňa Brejová E-mail: brejova@fmph.uniba.sk Office: M163 Course webpage: http://compbio.fmph.uniba.sk/vyuka/vpds/
More informationpast balancing schemes require maintenance of balance info at all times, are aggresive use work of searches to pay for work of rebalancing
1 Splay Trees Sleator and Tarjan, Self Adjusting Binary Search Trees JACM 32(3) 1985 The claim planning ahead. But matches previous idea of being lazy, letting potential build up, using it to pay for expensive
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 8 Greedy Algorithms V Huffman Codes Adam Smith Review Questions Let G be a connected undirected graph with distinct edge weights. Answer true or false: Let e be the
More informationBreadth First Search, Dijkstra s Algorithm for Shortest Paths
CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth
More informationINF2220: algorithms and data structures Series 1
Universitetet i Oslo Institutt for Informatikk I. Yu, D. Karabeg INF2220: algorithms and data structures Series 1 Topic Function growth & estimation of running time, trees (Exercises with hints for solution)
More informationAssignment 5: Solutions
Comp 21: Algorithms and Data Structures Assignment : Solutions 1. Heaps. (a) First we remove the minimum key 1 (which we know is located at the root of the heap). We then replace it by the key in the position
More informationHeaps and Priority Queues
Heaps and Priority Queues Motivation Situations where one has to choose the next most important from a collection. Examples: patients in an emergency room, scheduling programs in a multi-tasking OS. Need
More informationDictionary: an abstract data type
2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees
More informationLinear Time Selection
Linear Time Selection Given (x,y coordinates of N houses, where should you build road These lecture slides are adapted from CLRS.. Princeton University COS Theory of Algorithms Spring 0 Kevin Wayne Given
More informationSingle Source Shortest Paths
CMPS 00 Fall 015 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with an edge-weight
More informationCS 580: Algorithm Design and Analysis
CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting
More informationPriority queues implemented via heaps
Priority queues implemented via heaps Comp Sci 1575 Data s Outline 1 2 3 Outline 1 2 3 Priority queue: most important first Recall: queue is FIFO A normal queue data structure will not implement a priority
More informationEach internal node v with d(v) children stores d 1 keys. k i 1 < key in i-th sub-tree k i, where we use k 0 = and k d =.
7.5 (a, b)-trees 7.5 (a, b)-trees Definition For b a an (a, b)-tree is a search tree with the following properties. all leaves have the same distance to the root. every internal non-root vertex v has at
More informationComputing Connected Components Given a graph G = (V; E) compute the connected components of G. Connected-Components(G) 1 for each vertex v 2 V [G] 2 d
Data Structures for Disjoint Sets Maintain a Dynamic collection of disjoint sets. Each set has a unique representative (an arbitrary member of the set). x. Make-Set(x) - Create a new set with one member
More informationData Structures 1 NTIN066
Data Structures 1 NTIN066 Jirka Fink Department of Theoretical Computer Science and Mathematical Logic Faculty of Mathematics and Physics Charles University in Prague Winter semester 2017/18 Last change
More informationsearch trees. It is therefore important to obtain as full an understanding of the issue as possible. Additionally, there are practical applications fo
AVL Trees with Relaxed Balance Kim S. Larsen y University of Southern Denmar, Odense z Abstract The idea of relaxed balance is to uncouple the rebalancing in search trees from the updating in order to
More informationCS 4407 Algorithms Lecture: Shortest Path Algorithms
CS 440 Algorithms Lecture: Shortest Path Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Shortest Path Problem General Lemmas and Theorems. Algorithms Bellman-Ford
More informationChapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Shortest paths Minimum Spanning Tree Sofya Raskhodnikova 9/14/016 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,
More informationDictionary: an abstract data type
2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees
More informationA faster algorithm for the single source shortest path problem with few distinct positive lengths
A faster algorithm for the single source shortest path problem with few distinct positive lengths J. B. Orlin, K. Madduri, K. Subramani, and M. Williamson Journal of Discrete Algorithms 8 (2010) 189 198.
More informationDijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker
Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Goal:
More informationENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October
ENS Lyon Camp. Day 2. Basic group. Cartesian Tree. 26 October Contents 1 Cartesian Tree. Definition. 1 2 Cartesian Tree. Construction 1 3 Cartesian Tree. Operations. 2 3.1 Split............................................
More information16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]
418 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] 419 Dictionary implementation Hashing: implementation of dictionaries with expected very fast access times. Disadvantages
More information16. Binary Search Trees. [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap ]
423 16. Binary Search Trees [Ottman/Widmayer, Kap. 5.1, Cormen et al, Kap. 12.1-12.3] Dictionary implementation 424 Hashing: implementation of dictionaries with expected very fast access times. Disadvantages
More informationCMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.
CMPS 00 Fall 01 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with edge-weight function
More informationThe null-pointers in a binary search tree are replaced by pointers to special null-vertices, that do not carry any object-data
Definition 1 A red black tree is a balanced binary search tree in which each internal node has two children. Each internal node has a color, such that 1. The root is black. 2. All leaf nodes are black.
More informationA Tight Lower Bound for Top-Down Skew Heaps
A Tight Lower Bound for Top-Down Skew Heaps Berry Schoenmakers January, 1997 Abstract Previously, it was shown in a paper by Kaldewaij and Schoenmakers that for topdown skew heaps the amortized number
More informationShortest Path Algorithms
Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path 2 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node
More informationCMPUT 675: Approximation Algorithms Fall 2014
CMPUT 675: Approximation Algorithms Fall 204 Lecture 25 (Nov 3 & 5): Group Steiner Tree Lecturer: Zachary Friggstad Scribe: Zachary Friggstad 25. Group Steiner Tree In this problem, we are given a graph
More informationSplay Trees. CMSC 420: Lecture 8
Splay Trees CMSC 420: Lecture 8 AVL Trees Nice Features: - Worst case O(log n) performance guarantee - Fairly simple to implement Problem though: - Have to maintain etra balance factor storage at each
More informationCSE 202: Design and Analysis of Algorithms Lecture 3
CSE 202: Design and Analysis of Algorithms Lecture 3 Instructor: Kamalika Chaudhuri Announcement Homework 1 out Due on Tue Jan 24 in class No late homeworks will be accepted Greedy Algorithms Direct argument
More informationCSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26. Homework #2. ( Due: Nov 8 )
CSE548, AMS542: Analysis of Algorithms, Fall 2017 Date: Oct 26 Homework #2 ( Due: Nov 8 ) Task 1. [ 80 Points ] Average Case Analysis of Median-of-3 Quicksort Consider the median-of-3 quicksort algorithm
More informationDesign and Analysis of Algorithms
Design and Analysis of Algorithms CSE 5311 Lecture 21 Single-Source Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Single-Source
More informationChapter 6. Self-Adjusting Data Structures
Chapter 6 Self-Adjusting Data Structures Chapter 5 describes a data structure that is able to achieve an epected quer time that is proportional to the entrop of the quer distribution. The most interesting
More information1 Introduction A priority queue is a data structure that maintains a set of elements and supports operations insert, decrease-key, and extract-min. Pr
Buckets, Heaps, Lists, and Monotone Priority Queues Boris V. Cherkassky Central Econ. and Math. Inst. Krasikova St. 32 117418, Moscow, Russia cher@cemi.msk.su Craig Silverstein y Computer Science Department
More informationCS213d Data Structures and Algorithms
CS21d Data Structures and Algorithms Heaps and their Applications Milind Sohoni IIT Bombay and IIT Dharwad March 22, 2017 1 / 18 What did I see today? March 22, 2017 2 / 18 Heap-Trees A tree T of height
More informationWeak Heaps and Friends: Recent Developments
Weak Heaps and Friends: Recent Developments Stefan Edelkamp 1, Amr Elmasry 2, Jyrki Katajainen 3,4, 1) University of Bremen 2) Alexandria University 3) University of Copenhagen 4) Jyrki Katajainen and
More informationGreedy Alg: Huffman abhi shelat
L15 Greedy Alg: Huffman 4102 10.17.201 abhi shelat Huffman Coding image: wikimedia In testimony before the committee, Mr. Lew stressed that the Treasury Department would run out of extraordinary measures
More information4.8 Huffman Codes. These lecture slides are supplied by Mathijs de Weerd
4.8 Huffman Codes These lecture slides are supplied by Mathijs de Weerd Data Compression Q. Given a text that uses 32 symbols (26 different letters, space, and some punctuation characters), how can we
More informationSlides for CIS 675. Huffman Encoding, 1. Huffman Encoding, 2. Huffman Encoding, 3. Encoding 1. DPV Chapter 5, Part 2. Encoding 2
Huffman Encoding, 1 EECS Slides for CIS 675 DPV Chapter 5, Part 2 Jim Royer October 13, 2009 A toy example: Suppose our alphabet is { A, B, C, D }. Suppose T is a text of 130 million characters. What is
More informationAMORTIZED ANALYSIS. binary counter multipop stack dynamic table. Lecture slides by Kevin Wayne. Last updated on 1/24/17 11:31 AM
AMORTIZED ANALYSIS binary counter multipop stack dynamic table Lecture slides by Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on 1/24/17 11:31 AM Amortized analysis Worst-case
More informationData Structures 1 NTIN066
Data Structures 1 NTIN066 Jiří Fink https://kam.mff.cuni.cz/ fink/ Department of Theoretical Computer Science and Mathematical Logic Faculty of Mathematics and Physics Charles University in Prague Winter
More informationGreedy Algorithms and Data Compression. Curs 2018
Greedy Algorithms and Data Compression. Curs 2018 Greedy Algorithms A greedy algorithm, is a technique that always makes a locally optimal choice in the myopic hope that this choice will lead to a globally
More informationNon-context-Free Languages. CS215, Lecture 5 c
Non-context-Free Languages CS215, Lecture 5 c 2007 1 The Pumping Lemma Theorem. (Pumping Lemma) Let be context-free. There exists a positive integer divided into five pieces, Proof for for each, and..
More informationDiscrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees
, 2009 Lecture 5: Shortest Paths & Spanning Trees University of Twente m.uetz@utwente.nl wwwhome.math.utwente.nl/~uetzm/dw/ Shortest Path Problem "#$%&'%()*%"()$#+,&- Given directed "#$%&'()*+,%+('-*.#/'01234564'.*,'7+"-%/8',&'5"4'84%#3
More informationCS4311 Design and Analysis of Algorithms. Analysis of Union-By-Rank with Path Compression
CS4311 Design and Analysis of Algorithms Tutorial: Analysis of Union-By-Rank with Path Compression 1 About this lecture Introduce an Ackermann-like function which grows even faster than Ackermann Use it
More informationFunctional Data Structures
Functional Data Structures with Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2017-2-3 1 Part II Functional Data Structures 2 Chapter 1 Binary Trees 3 1 Binary Trees
More informationCMPS 6610 Fall 2018 Shortest Paths Carola Wenk
CMPS 6610 Fall 018 Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight function w
More informationAnother way of saying this is that amortized analysis guarantees the average case performance of each operation in the worst case.
Amortized Analysis: CLRS Chapter 17 Last revised: August 30, 2006 1 In amortized analysis we try to analyze the time required by a sequence of operations. There are many situations in which, even though
More informationSearch Trees. Chapter 10. CSE 2011 Prof. J. Elder Last Updated: :52 AM
Search Trees Chapter 1 < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 3 - Binary Search Trees Ø A binary search
More informationDisjoint-Set Forests
Disjoint-Set Forests Thanks for Showing Up! Outline for Today Incremental Connectivity Maintaining connectivity as edges are added to a graph. Disjoint-Set Forests A simple data structure for incremental
More informationDisjoint Sets : ADT. Disjoint-Set : Find-Set
Disjoint Sets : ADT Disjoint-Set Forests Make-Set( x ) Union( s, s ) Find-Set( x ) : π( ) : π( ) : ν( log * n ) amortized cost 6 9 {,, 9,, 6} set # {} set # 7 5 {5, 7, } set # Disjoint-Set : Find-Set Disjoint
More informationAlgorithms and Data Structures in the noisy comparison model and applications
Algorithms and Data Structures in the noisy comparison model and applications Nishanth Dikkala, Anil Shanbhag, Emmanouil Zampetakis Massachusetts Institute of Technology Abstract In contrast to classical
More informationCS 151. Red Black Trees & Structural Induction. Thursday, November 1, 12
CS 151 Red Black Trees & Structural Induction 1 Announcements Majors fair tonight 4:30-6:30pm in the Root Room in Carnegie. Come and find out about the CS major, or some other major. Winter Term in CS
More informationSingle Source Shortest Paths
CMPS 00 Fall 017 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight
More informationBreadth-First Search of Graphs
Breadth-First Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of Breadth-First Search of Graphs a) Single Source
More informationBinary Search Trees. Lecture 29 Section Robb T. Koether. Hampden-Sydney College. Fri, Apr 8, 2016
Binary Search Trees Lecture 29 Section 19.2 Robb T. Koether Hampden-Sydney College Fri, Apr 8, 2016 Robb T. Koether (Hampden-Sydney College) Binary Search Trees Fri, Apr 8, 2016 1 / 40 1 Binary Search
More informationFundamental Algorithms
Fundamental Algithms Chapter 4: AVL Trees Jan Křetínský Winter 2016/17 Chapter 4: AVL Trees, Winter 2016/17 1 Part I AVL Trees (Adelson-Velsky and Landis, 1962) Chapter 4: AVL Trees, Winter 2016/17 2 Binary
More informationSearch Trees. EECS 2011 Prof. J. Elder Last Updated: 24 March 2015
Search Trees < 6 2 > 1 4 = 8 9-1 - Outline Ø Binary Search Trees Ø AVL Trees Ø Splay Trees - 2 - Learning Outcomes Ø From this lecture, you should be able to: q Define the properties of a binary search
More informationBinary Search Trees. Motivation
Binary Search Trees Motivation Searching for a particular record in an unordered list takes O(n), too slow for large lists (databases) If the list is ordered, can use an array implementation and use binary
More informationVerified Analysis of Functional Data Structures
Verified Analysis of Functional Data Structures with Isabelle/HOL Tobias Nipkow Fakultät für Informatik Technische Universität München 2017-8-6 1 Lecture 1 Introduction Lecture 2 Search Trees Lecture 3
More informationCPSC 320 Sample Final Examination December 2013
CPSC 320 Sample Final Examination December 2013 [10] 1. Answer each of the following questions with true or false. Give a short justification for each of your answers. [5] a. 6 n O(5 n ) lim n + This is
More information1 Some loose ends from last time
Cornell University, Fall 2010 CS 6820: Algorithms Lecture notes: Kruskal s and Borůvka s MST algorithms September 20, 2010 1 Some loose ends from last time 1.1 A lemma concerning greedy algorithms and
More informationMA015: Graph Algorithms
MA015 3. Minimum cuts 1 MA015: Graph Algorithms 3. Minimum cuts (in undirected graphs) Jan Obdržálek obdrzalek@fi.muni.cz Faculty of Informatics, Masaryk University, Brno All pairs flows/cuts MA015 3.
More information6.889 Lecture 4: Single-Source Shortest Paths
6.889 Lecture 4: Single-Source Shortest Paths Christian Sommer csom@mit.edu September 19 and 26, 2011 Single-Source Shortest Path SSSP) Problem: given a graph G = V, E) and a source vertex s V, compute
More informationLecture 5: Splay Trees
15-750: Graduate Algorithms February 3, 2016 Lecture 5: Splay Trees Lecturer: Gary Miller Scribe: Jiayi Li, Tianyi Yang 1 Introduction Recall from previous lecture that balanced binary search trees (BST)
More informationLecture 2 September 4, 2014
CS 224: Advanced Algorithms Fall 2014 Prof. Jelani Nelson Lecture 2 September 4, 2014 Scribe: David Liu 1 Overview In the last lecture we introduced the word RAM model and covered veb trees to solve the
More information7.3 AVL-Trees. Definition 15. Lemma 16. AVL-trees are binary search trees that fulfill the following balance condition.
Definition 15 AVL-trees are binary search trees that fulfill the following balance condition. F eery node height(left sub-tree()) height(right sub-tree()) 1. Lemma 16 An AVL-tree of height h contains at
More informationThe Complexity of Constructing Evolutionary Trees Using Experiments
The Complexity of Constructing Evolutionary Trees Using Experiments Gerth Stlting Brodal 1,, Rolf Fagerberg 1,, Christian N. S. Pedersen 1,, and Anna Östlin2, 1 BRICS, Department of Computer Science, University
More informationne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn
n-negative Edge Costs: optimal choice: u U with d(u) minimal. e use a priority queue (de nition on next slide) PQ to maintain the set of pairs, d(u)) ; u U } and obtain Dijkstra s Algorithm: ne a priority
More informationOptimal Color Range Reporting in One Dimension
Optimal Color Range Reporting in One Dimension Yakov Nekrich 1 and Jeffrey Scott Vitter 1 The University of Kansas. yakov.nekrich@googlemail.com, jsv@ku.edu Abstract. Color (or categorical) range reporting
More informationCS 161: Design and Analysis of Algorithms
CS 161: Design and Analysis of Algorithms Greedy Algorithms 1: Shortest Paths In Weighted Graphs Greedy Algorithm BFS as a greedy algorithm Shortest Paths in Weighted Graphs Dijsktra s Algorithm Greedy
More informationChapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.
Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and
More informationPart IA Algorithms Notes
Part IA Algorithms Notes 1 Sorting 1.1 Insertion Sort 1 d e f i n s e r t i o n S o r t ( a ) : 2 f o r i from 1 i n c l u d e d to l e n ( a ) excluded : 3 4 j = i 1 5 w h i l e j >= 0 and a [ i ] > a
More informationOutline. Computer Science 331. Cost of Binary Search Tree Operations. Bounds on Height: Worst- and Average-Case
Outline Computer Science Average Case Analysis: Binary Search Trees Mike Jacobson Department of Computer Science University of Calgary Lecture #7 Motivation and Objective Definition 4 Mike Jacobson (University
More informationEfficient Reassembling of Graphs, Part 1: The Linear Case
Efficient Reassembling of Graphs, Part 1: The Linear Case Assaf Kfoury Boston University Saber Mirzaei Boston University Abstract The reassembling of a simple connected graph G = (V, E) is an abstraction
More informationOrdered Dictionary & Binary Search Tree
Ordered Dictionary & Binary Search Tree Finite map from keys to values, assuming keys are comparable (). insert(k, v) lookup(k) aka find: the associated value if any delete(k) (Ordered set: No values;
More informationAVL Trees. Manolis Koubarakis. Data Structures and Programming Techniques
AVL Trees Manolis Koubarakis 1 AVL Trees We will now introduce AVL trees that have the property that they are kept almost balanced but not completely balanced. In this way we have O(log n) search time
More informationCS 466/666 Course Notes
Fall 2018 CS 466/666 Course Notes TABLE OF CONTENTS richardwu.ca CS 466/666 Course Notes Design and Analysis of Algorithms Anna Lubiw Fall 2018 University of Waterloo Last Revision: December 12, 2018 Table
More informationSlides credited from Hsueh-I Lu & Hsu-Chun Hsiao
Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao Homework 3 released Due on 12/13 (Thur) 14:20 (one week only) Mini-HW 9 released Due on 12/13 (Thur) 14:20 Homework 4 released Due on 1/3 (Thur) 14:20 (four
More information8: Splay Trees. Move-to-Front Heuristic. Splaying. Splay(12) CSE326 Spring April 16, Search for Pebbles: Move found item to front of list
: Splay Trees SE Spring 00 pril, 00 Move-to-Front Heuristic Search for ebbles: Fred Wilma ebbles ino Fred Wilma ino ebbles Move found item to front of list Frequently searched items will move to start
More informationCSCE 750 Final Exam Answer Key Wednesday December 7, 2005
CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note
More informationRandom Dyadic Tilings of the Unit Square
Random Dyadic Tilings of the Unit Square Svante Janson, Dana Randall and Joel Spencer June 24, 2002 Abstract A dyadic rectangle is a set of the form R = [a2 s, (a+1)2 s ] [b2 t, (b+1)2 t ], where s and
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401J LECTURE 14 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Charles E. Leiserson Paths in graphs
More informationInge Li Gørtz. Thank you to Kevin Wayne for inspiration to slides
02110 Inge Li Gørtz Thank you to Kevin Wayne for inspiration to slides Welcome Inge Li Gørtz. Reverse teaching and discussion of exercises: 3 teaching assistants 8.00-9.15 Group work 9.15-9.45 Discussions
More informationChapter 10 Search Structures
Chapter 1 Search Structures 1 1.2 AVL Trees : 동기 Objective : maintain binary search tree structure for O(log n) access time with dynamic changes of identifiers (i.e., elements) in the tree. JULY APR AUG
More informationOn Adaptive Integer Sorting
On Adaptive Integer Sorting Anna Pagh 1, Rasmus Pagh 1, and Mikkel Thorup 2 1 IT University of Copenhagen, Rued Langgaardsvej 7, 2300 København S, Denmark {annao, pagh}@itu.dk 2 AT&T Labs Research, Shannon
More informationQuiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)
Introduction to Algorithms October 13, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Quiz 1 Solutions Quiz 1 Solutions Problem 1. We
More informationCS Data Structures and Algorithm Analysis
CS 483 - Data Structures and Algorithm Analysis Lecture VII: Chapter 6, part 2 R. Paul Wiegand George Mason University, Department of Computer Science March 22, 2006 Outline 1 Balanced Trees 2 Heaps &
More information