Greedy Alg: Huffman abhi shelat
|
|
- Bonnie Harmon
- 6 years ago
- Views:
Transcription
1 L15 Greedy Alg: Huffman abhi shelat
2 Huffman Coding
3 image: wikimedia
4 In testimony before the committee, Mr. Lew stressed that the Treasury Department would run out of extraordinary measures to free up cash in a matter of days. At that point, the country s bills might overwhelm its cash on hand plus any receipts from taxes or other sources, leading to an unprecedented default.mr. Lew said that Treasury had no workarounds to avoid breaching the debt ceiling. There is no plan other than raising the debt limit, he said. The legal issues, even regarding interest and principal on the debt, are complicated.
5 m In testimony before the committee, Mr. Lew stressed that the Treasury Department would run out of extraordinary measures to free up cash in a matter of days. At that point, the country s bills might overwhelm its cash on hand plus any receipts from taxes or other sources, leading to an unprecedented default.mr. Lew said that Treasury had no workarounds to avoid breaching the debt ceiling. There is no plan other than raising the debt limit, he said. The legal issues, even regarding interest and principal on the debt, are complicated.
6 def: cost of an encoding B(T,{f c })= X c2c f c `c e: i: o: u: p: g: b: f:
7 e: 240 i: a: 199 o: r: n: 1521 t: s: 192 l: c: 1007 u: 7211 p: 7077 m: d: 6007 h: y: g: b: 4051 f: v: 2010 k: w: 125 z: 49 x: 6926 q: 729 j: character frequency e i a o r n t s l c u p m d h y g b f v k w z x q j
8 morse code
9 def: prefix code e: 25 0 i: o: u: p: g: b: f:
10 prefix code binary tree
11 e: 25 0 i: o: u: p: g: b: f: code to binary tree
12 e: i: o: u: p: e i o u p use tree to encode messages
13 goal given the character frequencies {f c } c C produce a prefix code T with smallest cost min T B(T,{f c})
14 property y Lemma:optimal tree must be full. x a b
15 divide & conquer?
16 counter-example e: 2 i: 25 o: 20 u: 1 p: 5
17 )"!'(!## &$# %$ $% "$ "#!" e i o u p g b f
18 !'(!## &$# %$ $% "$ )" e i o u p g "#!" b f
19 !'(!## &$# %$ $% )" "$ e i o u p g "#!" b f
20 200 i o 1 25 e e: i: o: u: p: g: b: f: u 7 p g 40 b 24 f
21 objective
22 lemma: exchange argument
23 lemma: T exchange argument Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for y x a b
24 lemma: exchange argument Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for T T y b x a a b x y
25 exchange argument proof: lemma: Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for
26 exchange argument lemma: Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for T y first step x a b
27 exchange argument lemma: Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for T T y first step y x a a b x b f a f b f x f y f y f b f x f a
28 T T y y x f x f a a a b x b
29 T T y y x f x f a a a b x b B(T )= f c c + f x x + f a a B(T )= f c c + f x x + f a a c c B(T ) B(T ) 0
30 T T y b a a x b x y B(T ) B(T ) 0
31 T T T y y b x a a a b x b x y
32 T T T y y b x a a a b x b x y B(T ) B(T ) 0 B(T ) B(T ) 0 Tis also optimal
33 exchange argument lemma: Let x, y C be characters with smallest frequencies f x,f y. There exists an optimal prefix code T for C in which x, y are siblings. That is, the codes for x, y have the same length and only di er in the last bit. The optimal solution for consists of computing an optimal solution for T T y b x a a b x y
34 f c!'(!## &$# %$ $% "$ optimal sub-structure f x "# f y!"
35 f c optimal sub-structure!'(!## &$# %$ $% "$ f x "# f y!" problem of size n!'(!## &$# %$ $% "$ )" f c problem of size n-1 f z
36 f c optimal sub-structure!'(!## &$# %$ $% "$ problem of size n!'(!## &$# %$ $% "$ )" f c problem of size n-1 f x "# f z f y!" Lemma:
37 f c optimal sub-structure!'(!## &$# %$ $% "$ problem of size n!'(!## &$# %$ $% "$ )" f c problem of size n-1 f x "# f z f y!" Lemma: The optimal solution for T consists of computing an optimal solution for T and replacing the left z with a node having children x, y.
38 T z z
39 T T z x y B(T ) B(T )
40 T T z x y B(T ) B(T ) B(T )=B(T ) f x f y
41 Suppose T is not optimal
42 Suppose U T is not optimal B(U) <B(T ) x y
43 Suppose U T is not optimal B(U) <B(T ) x y U z
44 Suppose U T is not optimal B(U) <B(T ) x y B(U )=B(U) f x f y U < B(t) - fx - fy z But this implies that B(T ) was not optimal.
45 therefore T z x y
46 summary of argument
47 MST
48 connecting houses image: thefranciscofamily.org,
49 connecting houses image: thefranciscofamily.org,
50 connecting houses image: thefranciscofamily.org,
51 connecting houses image: thefranciscofamily.org,
52 connecting houses image: thefranciscofamily.org,
53 connecting houses image: thefranciscofamily.org,
54 connecting houses image: thefranciscofamily.org,
55 connecting houses image: thefranciscofamily.org,
56 b d g 10 2 a 9 e 5 9 i c 1 f 6 h
57 graphs clrs [ch 22]
58
59 representation G =(V,E) adjacency list space: time list neighbors: time check an edge:
60 representation G =(V,E) adjacency matrix space: time list neighbors: time check an edge:
61 definition: path a sequence of nodes with the property that simple path: cycle:
62 definition:tree connected graph: a tree is
63 what we want: b d g 10 2 a 9 e 5 9 i c 1 f 6 h
64 minimum spanning tree looking for a set of edges that T E (a) connects all vertices (b) has the least cost min (u,v) T w(u, v)
65 looking for a set of edges thatt E (a) connects all vertices (b) has the least cost facts min (u,v) T w(u, v) how many edges does solution have? does solution have a cycle?
66 strategy start with an empty set of edges A repeat for v-1 times: add lightest edge that does not create a cycle
67 example b d g a 9 e 5 9 i c 1 f 6 h
68 kruskal b d g a 9 e 5 9 i c 1 f 6 h
69 kruskal b d g a 9 e 5 9 i c 1 f 6 h
70 kruskal b d g a 9 e 5 9 i c 1 f 6 h
71 kruskal b d g a 9 e 5 9 i c 1 f 6 h
72 kruskal b d g a 9 e 5 9 i c 1 f 6 h
73 kruskal b d g a 9 e 5 9 i c 1 f 6 h
74 kruskal b d g a 9 e 5 9 i c 1 f 6 h
75 kruskal b d g a 9 e 5 9 i c 1 f 6 h
76 kruskal e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7 e d f c b a i g h 7
77 why does this work? 1 T 2 repeat V 1 times: add to T the lightest edge e E that does not create a cycle
78 definition: cut
79 example of a cut b d g a 9 e 5 9 i c 1 f 6 h
80 definition: crossing a cut
81 definition: crossing a cut an edge e =(u, crosses v) a graph cut (S,V-S) if u S v V S b d g a 9 e 5 9 i c 1 f 6 h
82 example of a crossing b d g a 9 e 5 9 i c 1 f 6 h
83 definition: respect
84 theorem: cut property
85 suppose the set of edges thm: cut property A is part of an m.s.t. let (S, V S) be any cut that respects A. let edge e be the min-weight edge across (S, V S) then: A {e} is part of an m.s.t.
86 example of theorem b d g a 9 e 5 9 i c 1 f 6 h
87 d 5 7 h 9 g 11 2 e 6 i b f a 12 c
88 Theorem 2 Suppose the set of edges A is part of a minimum spanning tree of G = (V, E). Let (S, V S) be any cut that respects A and let e be the edge with the minimum weight that crosses (S, V S). Then the set A {e} is part of a minimum spanning tree.
89 proof of cut thm d 7 5 g i e h 6 c 1 f 9 12 b 10 a
90 Kruskal-pseudocode(G) correctness 1 A 2 repeat V 1 times: add to A the lightest edge e E that does not create a cycle
91 Kruskal-pseudocode(G) correctness 1 A 2 repeat V 1 times: add to A the lightest edge e E that does not create a cycle proof: by induction. in step 1, A is part of some MST. suppose that after k steps, A is part of some MST (line 2). in line, we add an edge e to A.
92 cases for edge e
93 cases for edge e e must be lightest edge crossing
94 analysis? Kruskal-pseudocode(G) 1 A 2 repeat V 1 times: add to A the lightest edge e E that does not create a cycle
95 General-MST-Strategy(G =(V,E)) 1 A 2 repeat V 1 times: 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}
96 prim General-MST-Strategy(G =(V,E)) 1 A 2 repeat V 1 times: 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} A is a subtree edge e is lightest edge that grows the subtree
97 prim b d g a 9 e 5 9 i c 1 f 6 h
98 prim b d g a 9 e 5 9 i c 1 f 6 h
99 prim b d g a 9 e 5 9 i c 1 f 6 h
100 prim b d g a 9 e 5 9 i c 1 f 6 h
101 prim b d g a 9 e 5 9 i c 1 f 6 h
102 prim b d g a 9 e 5 9 i c 1 f 6 h
103 prim b d g a 9 e 5 9 i c 1 f 6 h
104 prim b d g a 9 e 5 9 i c 1 f 6 h
105 prim b d g a 9 e 5 9 i c 1 f 6 h
106 idea: implementation
107 implementation
108 new data structure
109 binary heap full tree, key value <= to key of children
110 binary heap full tree, key value <= to key of children ' &# ( && &' ) :!' ""
111 binary heap full tree, key value <= to key of children ' &# ( && &' ) :!' "" %
112 binary heap full tree, key value <= to key of children ' &# ( && % ) :!' "" &'
113 binary heap full tree, key value <= to key of children how to extractmin? ' % ( && &# ) :!' "" &'
114 binary heap full tree, key value <= to key of children how to extractmin? &' % ( && &# ) :!' "" &'
115 binary heap full tree, key value <= to key of children how to extractmin? ( % &' && &# ) :!' "" &'
116 binary heap full tree, key value <= to key of children how to extractmin? ( % ) && &# &' :!' "" &'
117 binary heap full tree, key value <= to key of children how to decreasekey? ( % ) && &# &' :!' ""
118 binary heap full tree, key value <= to key of children how to decreasekey? ( $ ) && % &' :!' ""
119 implementation use a priority queue to keep track of light edges insert: makequeue: extractmin: decreasekey:
120 algorithm
121 prim(g =(V,E)) implementation 1 Q Q is a Priority Queue 2 Initialize each v V with key k v, v nil Pick a starting node r and set k r 0 4 Insert all nodes into Q with key k v. 5 while Q = 6 do u extract-min(q) 7 for each v Adj (u) do if v Q and w(u, v) <k v 9 then v u 10 decrease-key(q, v, w(u, v)) Sets k v w(u, v)
abhi shelat
L15 4102.17.2016 abhi shelat Huffman image: wikimedia Alice m Bob m Alice m Bob MOSCOW President Vladimir V. Putin s typically theatrical order to withdraw the bulk of Russian forces from Syria, a process
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 informationBFS Dijkstra. Oct abhi shelat
4102 BFS Dijkstra Oct 22 2009 abhi shelat breadth first search bfs(g, a) 1 2 a b 1 2 d c e f g 2 h bfs theorem Theorem 1 (CLRS, p. 599) Let G =(V, E) be a graph and suppose that BFS is run on G from vertex
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 informationGreedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10
Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 10 CSE 101: Design and analysis of algorithms Greedy algorithms Reading: Kleinberg and Tardos, sections 4.1, 4.2, and 4.3 Homework 4
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 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 informationCSE 421 Greedy: Huffman Codes
CSE 421 Greedy: Huffman Codes Yin Tat Lee 1 Compression Example 100k file, 6 letter alphabet: File Size: ASCII, 8 bits/char: 800kbits 2 3 > 6; 3 bits/char: 300kbits better: 2.52 bits/char 74%*2 +26%*4:
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 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 information3 Greedy Algorithms. 3.1 An activity-selection problem
3 Greedy Algorithms [BB chapter 6] with different examples or [Par chapter 2.3] with different examples or [CLR2 chapter 16] with different approach to greedy algorithms 3.1 An activity-selection problem
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 informationGeneral Methods for Algorithm Design
General Methods for Algorithm Design 1. Dynamic Programming Multiplication of matrices Elements of the dynamic programming Optimal triangulation of polygons Longest common subsequence 2. Greedy Methods
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 information1 Basic Definitions. 2 Proof By Contradiction. 3 Exchange Argument
1 Basic Definitions A Problem is a relation from input to acceptable output. For example, INPUT: A list of integers x 1,..., x n OUTPUT: One of the three smallest numbers in the list An algorithm A solves
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 informationIS 709/809: Computational Methods in IS Research Fall Exam Review
IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm
More informationGreedy. Outline CS141. Stefano Lonardi, UCR 1. Activity selection Fractional knapsack Huffman encoding Later:
October 5, 017 Greedy Chapters 5 of Dasgupta et al. 1 Activity selection Fractional knapsack Huffman encoding Later: Outline Dijkstra (single source shortest path) Prim and Kruskal (minimum spanning tree)
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 informationCS 253: Algorithms. Chapter 24. Shortest Paths. Credit: Dr. George Bebis
CS : Algorithms Chapter 4 Shortest Paths Credit: Dr. George Bebis Shortest Path Problems How can we find the shortest route between two points on a road map? Model the problem as a graph problem: Road
More information21. Dynamic Programming III. FPTAS [Ottman/Widmayer, Kap. 7.2, 7.3, Cormen et al, Kap. 15,35.5]
575 21. Dynamic Programming III FPTAS [Ottman/Widmayer, Kap. 7.2, 7.3, Cormen et al, Kap. 15,35.5] Approximation 576 Let ε (0, 1) given. Let I opt an optimal selection. No try to find a valid selection
More informationFibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20. Princeton University COS 4 Theory of Algorithms Spring 2002 Kevin Wayne Priority Queues Operation mae-heap insert find- delete- union
More informationDiscrete Optimization 2010 Lecture 2 Matroids & Shortest Paths
Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids
More informationCS4800: Algorithms & Data Jonathan Ullman
CS4800: Algorithms & Data Jonathan Ullman Lecture 22: Greedy Algorithms: Huffman Codes Data Compression and Entropy Apr 5, 2018 Data Compression How do we store strings of text compactly? A (binary) code
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 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 informationCS781 Lecture 3 January 27, 2011
CS781 Lecture 3 January 7, 011 Greedy Algorithms Topics: Interval Scheduling and Partitioning Dijkstra s Shortest Path Algorithm Minimum Spanning Trees Single-Link k-clustering Interval Scheduling Interval
More informationLecture 1 : Data Compression and Entropy
CPS290: Algorithmic Foundations of Data Science January 8, 207 Lecture : Data Compression and Entropy Lecturer: Kamesh Munagala Scribe: Kamesh Munagala In this lecture, we will study a simple model for
More informationAnalysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes
Analysis of Algorithms Single Source Shortest Path Andres Mendez-Vazquez November 9, 01 1 / 108 Outline 1 Introduction Introduction and Similar Problems General Results Optimal Substructure Properties
More informationDivide-and-Conquer Algorithms Part Two
Divide-and-Conquer Algorithms Part Two Recap from Last Time Divide-and-Conquer Algorithms A divide-and-conquer algorithm is one that works as follows: (Divide) Split the input apart into multiple smaller
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 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 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 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 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 informationInformation Theory and Statistics Lecture 2: Source coding
Information Theory and Statistics Lecture 2: Source coding Łukasz Dębowski ldebowsk@ipipan.waw.pl Ph. D. Programme 2013/2014 Injections and codes Definition (injection) Function f is called an injection
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 informationCMPSCI611: The Matroid Theorem Lecture 5
CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that
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 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 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 informationDiscrete Mathematics
Discrete Mathematics Trees H. Turgut Uyar Ayşegül Gençata Yayımlı Emre Harmancı 2001-2016 License You are free to: c 2001-2016 T. Uyar, A. Yayımlı, E. Harmancı Share copy and redistribute the material
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 informationAutumn Coping with NP-completeness (Conclusion) Introduction to Data Compression
Autumn Coping with NP-completeness (Conclusion) Introduction to Data Compression Kirkpatrick (984) Analogy from thermodynamics. The best crystals are found by annealing. First heat up the material to let
More informationCS 161: Design and Analysis of Algorithms
CS 161: Design and Analysis of Algorithms Greedy Algorithms 3: Minimum Spanning Trees/Scheduling Disjoint Sets, continued Analysis of Kruskal s Algorithm Interval Scheduling Disjoint Sets, Continued Each
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 informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/8.40J/SMA550 Lecture 7 Prof. Erik Demaine Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v v L v k is defined
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 informationMinimum Spanning Trees
Minimum Spanning Trees We now know how to compute the minimum cost path from a start node to every other node in a graph. What other interesting problems can we solve using graphs? onstructing a Network
More informationCSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD
Course Overview Material that will be covered in the course: Basic graph algorithms Algorithm Design Techniques Greedy Algorithms Divide and Conquer Dynamic Programming Network Flows Computational intractability
More informationData Structures in Java
Data Structures in Java Lecture 20: Algorithm Design Techniques 12/2/2015 Daniel Bauer 1 Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways of
More informationAlgorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search
Algorithms Booklet 2010 Note: in all algorithms, unless stated otherwise, the input graph G is represented by adjacency lists. 1 Graph Searching 1.1 Breadth First Search Algorithm 1: BFS(G, s) Input: G
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 informationCS583 Lecture 11. Many slides here are based on D. Luebke slides. Review: Dynamic Programming
// CS8 Lecture Jana Kosecka Dynamic Programming Greedy Algorithms Many slides here are based on D. Luebke slides Review: Dynamic Programming A meta-technique, not an algorithm (like divide & conquer) Applicable
More informationAn Introduction to Matroids & Greedy in Approximation Algorithms
An Introduction to Matroids & Greedy in Approximation Algorithms (Juliàn Mestre, ESA 2006) CoReLab Monday seminar presentation: Evangelos Bampas 1/21 Subset systems CoReLab Monday seminar presentation:
More informationICS 252 Introduction to Computer Design
ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401J LECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Erik Demaine November 14, 005 Copyright
More informationCS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS
UNIT V GRAPHS Representation of Graphs Breadth-first search Depth-first search Topological sort Minimum Spanning Trees Kruskal and Prim algorithm Shortest path algorithm Dijkstra s algorithm Bellman-Ford
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 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 informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS6000: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v 1 v L v k
More informationMatching Residents to Hospitals
Midterm Review Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and
More informationFirst Lemma. Lemma: The cost function C h has the ASI-Property. Proof: The proof can be derived from the definition of C H : C H (AUVB) = C H (A)
IKKBZ First Lemma Lemma: The cost function C h has the ASI-Property. Proof: The proof can be derived from the definition of C H : and, hence, C H (AUVB) = C H (A) +T(A)C H (U) +T(A)T(U)C H (V) +T(A)T(U)T(V)C
More informationLecture 9. Greedy Algorithm
Lecture 9. Greedy Algorithm T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algorithms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Choo choo@skku.edu Copyright 2000-2018
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 informationContents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression
Contents Lecture 4 Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Jonas Skeppstedt (jonasskeppstedt.net) Lecture 4 2018
More informationProof methods and greedy algorithms
Proof methods and greedy algorithms Magnus Lie Hetland Lecture notes, May 5th 2008 1 Introduction This lecture in some ways covers two separate topics: (1) how to prove algorithms correct, in general,
More informationContext-Free Languages
CS:4330 Theory of Computation Spring 2018 Context-Free Languages Non-Context-Free Languages Haniel Barbosa Readings for this lecture Chapter 2 of [Sipser 1996], 3rd edition. Section 2.3. Proving context-freeness
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 10/31/16
60.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 0/3/6 6. Introduction We talked a lot the last lecture about greedy algorithms. While both Prim
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 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 informationText Compression. Jayadev Misra The University of Texas at Austin December 5, A Very Incomplete Introduction to Information Theory 2
Text Compression Jayadev Misra The University of Texas at Austin December 5, 2003 Contents 1 Introduction 1 2 A Very Incomplete Introduction to Information Theory 2 3 Huffman Coding 5 3.1 Uniquely Decodable
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 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 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 informationEE 121: Introduction to Digital Communication Systems. 1. Consider the following discrete-time communication system. There are two equallly likely
EE 11: Introduction to Digital Communication Systems Midterm Solutions 1. Consider the following discrete-time communication system. There are two equallly likely messages to be transmitted, and they are
More informationSIGNAL COMPRESSION Lecture 7. Variable to Fix Encoding
SIGNAL COMPRESSION Lecture 7 Variable to Fix Encoding 1. Tunstall codes 2. Petry codes 3. Generalized Tunstall codes for Markov sources (a presentation of the paper by I. Tabus, G. Korodi, J. Rissanen.
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 informationCS325: Analysis of Algorithms, Fall Final Exam
CS: Analysis of Algorithms, Fall 0 Final Exam I don t know policy: you may write I don t know and nothing else to answer a question and receive percent of the total points for that problem whereas a completely
More informationGreedy Algorithms and Data Compression. Curs 2017
Greedy Algorithms and Data Compression. Curs 2017 Greedy Algorithms An optimization problem: Given of (S, f ), where S is a set of feasible elements and f : S R is the objective function, find a u S, which
More informationFundamental Algorithms
Fundamental Algorithms Chapter 5: Searching Michael Bader Winter 2014/15 Chapter 5: Searching, Winter 2014/15 1 Searching Definition (Search Problem) Input: a sequence or set A of n elements (objects)
More informationCoding of memoryless sources 1/35
Coding of memoryless sources 1/35 Outline 1. Morse coding ; 2. Definitions : encoding, encoding efficiency ; 3. fixed length codes, encoding integers ; 4. prefix condition ; 5. Kraft and Mac Millan theorems
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 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 informationAlgorithm Design Strategies V
Algorithm Design Strategies V Joaquim Madeira Version 0.0 October 2016 U. Aveiro, October 2016 1 Overview The 0-1 Knapsack Problem Revisited The Fractional Knapsack Problem Greedy Algorithms Example Coin
More informationCS60007 Algorithm Design and Analysis 2018 Assignment 1
CS60007 Algorithm Design and Analysis 2018 Assignment 1 Palash Dey and Swagato Sanyal Indian Institute of Technology, Kharagpur Please submit the solutions of the problems 6, 11, 12 and 13 (written in
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 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 informationSIGNAL COMPRESSION Lecture Shannon-Fano-Elias Codes and Arithmetic Coding
SIGNAL COMPRESSION Lecture 3 4.9.2007 Shannon-Fano-Elias Codes and Arithmetic Coding 1 Shannon-Fano-Elias Coding We discuss how to encode the symbols {a 1, a 2,..., a m }, knowing their probabilities,
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 informationChapter 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 informationFINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)
FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) The final exam will be on Thursday, May 12, from 8:00 10:00 am, at our regular class location (CSI 2117). It will be closed-book and closed-notes, except
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 6 Greedy Algorithms Interval Scheduling Interval Partitioning Scheduling to Minimize Lateness Sofya Raskhodnikova S. Raskhodnikova; based on slides by E. Demaine,
More informationAlgorithm Design and Analysis (NTU CSIE, Fall 2017) Homework #3. Homework #3. Due Time: 2017/12/14 (Thu.) 17:20 Contact TAs:
Instructions and Announcements Homework #3 ue Time: 017/1/14 (Thu.) 17:0 Contact TAs: ada-ta@csie.ntu.edu.tw There are four programming problems and two handwritten problems. Programming. The judge system
More informationNotes on induction proofs and recursive definitions
Notes on induction proofs and recursive definitions James Aspnes December 13, 2010 1 Simple induction Most of the proof techniques we ve talked about so far are only really useful for proving a property
More informationIntroduction to Algorithms
Introduction to Algorithms, Lecture 5 // Introduction to Algorithms 6.46J/.4J LECTURE Shortest Paths I Properties o shortest paths Dijkstra s Correctness Analysis Breadth-irst Pro. Manolis Kellis March,
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17
601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Dynamic Programming II Date: 10/12/17 12.1 Introduction Today we re going to do a couple more examples of dynamic programming. While
More informationSearch Algorithms. Analysis of Algorithms. John Reif, Ph.D. Prepared by
Search Algorithms Analysis of Algorithms Prepared by John Reif, Ph.D. Search Algorithms a) Binary Search: average case b) Interpolation Search c) Unbounded Search (Advanced material) Readings Reading Selection:
More informationChapter 11. Min Cut Min Cut Problem Definition Some Definitions. By Sariel Har-Peled, December 10, Version: 1.
Chapter 11 Min Cut By Sariel Har-Peled, December 10, 013 1 Version: 1.0 I built on the sand And it tumbled down, I built on a rock And it tumbled down. Now when I build, I shall begin With the smoke from
More informationJoin Ordering. Lemma: The cost function C h has the ASI-Property. Proof: The proof can be derived from the definition of C H :
IKKBZ First Lemma Lemma: The cost function C h has the ASI-Property. Proof: The proof can be derived from the definition of C H : and, hence, C H (AUVB) = C H (A) +T (A)C H (U) +T (A)T (U)C H (V ) +T (A)T
More information