CSE431/531 Homework 3 Solutions
|
|
- Kevin Hunt
- 5 years ago
- Views:
Transcription
1 CSE431/531 Homework 3 Solutions Due: Oct 19, of 11
2 1 Problem 1 input : A convex polygon P with vertices [v 1, v 2,..., v n ] output: A minimum weight triangulation of P A[1 : n, 1 : n] ( 1) ; /* n n array, initialized to 1 */ B[1 : n, 1 : n] ( 1); Cost(1,n); PrintTriangulation(1,n); Function PrintTriangulation(i,j) if j i 3 then k B[i, j]; if k = n then Print((v i+1, v j )); Print((v i, v k )); PrintTriangulation(i,k); PrintTriangulation(k,j); /* Cost(i,j) returns the cost of the minimum weight triangulation of the vertices between v i and v j. A is used to memoize Cost() and B is used to store the diagonals used */ Function Cost(i,j) if j i 2 then return 0 ; /* Already triangulated */ if A[i, j] 1 then return A[i, j] ; /* Return memoized value */ C[1 : n] ; /* To handle edges originating from v i */ for k [i + 2, j 1] do C[k] Distance(v i, v j ) + Cost(i, k) + Cost(k, j); /* If there is no edge from v i there must be one from v i+1 to v j */ C[n] Distance(v i+1, v j ) + Cost(i + 1, j); A[i, j] min k B[i, j] argmin k (C[k]); (C[k]); 2 of 11
3 2 Problem D Case input : A string a = [a 1, a 2,..., a n ] and a string b = [b 1, b 2,..., b m ] output: A shortest common superstring of a and b A[0 : m, 0 : n] 0; /* A[i,j] = Cost of superstring(a[i:],b[j:]) */ for j [0, n] do A[m, j] n j; for i [0, m] do A[i, n] m i; for i [m 1, m 2,..., 0] do for j [n 1, n 2,..., 0] do if a i = b j then A[i, j] 1 + A[i + 1, j + 1]; A[i, j] 1 + min (A[i, j + 1], A[i + 1, j]); i 0; j 0; while i < m or j < n do if i = m or A[i, j] = 1 + A[i, j + 1] then Print(b j ); if j = n or A[i, j] = 1 + A[i + 1, j] then 3 of 11
4 2.2 3D Case input : Strings a = [a 1...a m ], b = [b 1...b n ], c = [c 1...c p ] output: A shortest common superstring of a, b and c A[0 : m, 0 : n, 0 : p] 0; /* A[i,j,k] = Cost of superstring(a[i:],b[j:],c[k:]) */ Initialize(); Compute(); PrintResult(); Function Initialize for i [0, m] do for j [0, n] do for k [0, p] do if i = m then A[i, j, k] 2Dsuperstring(b[j :], c[k :]); if j = n then A[i, j, k] 2Dsuperstring(a[i :], c[k :]); if k = p then A[i, j, k] 2Dsuperstring(a[i :], b[j :]); 4 of 11
5 Function Compute for i [m 1, m 2,..., 0] do for j [n 1, n 2,..., 0] do for k [p 1, p 2,..., 0] do cases[1 : 7] ; if a i = b j = c k then cases[1] 1 + A[i + 1, j + 1, k + 1]; if a i = b j then cases[2] 1 + A[i + 1, j + 1, k]; if b j = c k then cases[3] 1 + A[i, j + 1, k + 1]; if a i = c k then cases[4] 1 + A[i + 1, j, k + 1]; cases[5] 1 + A[i + 1, j, k]; cases[6] 1 + A[i, j + 1, k]; cases[7] 1 + A[i, j, k + 1]; A[i, j, k] 1 + min (cases[1 : 7]); 5 of 11
6 Function PrintResult i 0; j 0; k 0; while i < m or j < n or k < p do if i m and j n and k p and A[i, j, k] = 1 + A[i + 1, j + 1, k + 1] then k k + 1; if i m and j n and A[i, j, k] = 1 + A[i + 1, j + 1, k] then if i m and k p and A[i, j, k] = 1 + A[i + 1, j, k + 1] then k k + 1; if j n and k p and A[i, j, k] = 1 + A[i, j + 1, k + 1] then Print(b j ); k k + 1; if i m and A[i, j, k] = 1 + A[i + 1, j, k] then if j n and A[i, j, k] = 1 + A[i, j + 1, k] then Print(b j ); if k p and A[i, j, k] = 1 + A[i, j, k + 1] then Print(c k ); k k + 1; 6 of 11
7 3 Problem Part a Let cost(n) be the cost computing T (n) directly. We have: n 1 cost(n) = cost(i) + cost(i 1) i=1 n 1 2cost(i 1) = i=1 i=1 n 2 2 = 2 n 2 = ( 2) n (1) 3.2 Part b To solve the problem in O(n 2 ) time memoize the value T (i). Then cost(n) = 3.3 Part c n 2n = O(n 2 ) (2) i=1 input : Integer n output: T (n) A[0 : n] 2; for i [2, n] do A[i] A[i 1] + A[i 1] A[i 2]; return A[n] 7 of 11
8 4 Problem 4 input : Binary tree T with vertices v 1..v n and root v 1, Weight function w, Number of cuts k output: Minimum weight forest /* T Cost[i, j] = The cost of the optimal subtree at v i with j cuts */ T Cost[1 : n, 1 : k] 0; /* CCCost[i, j] = The cost of the connected component containing v i of the optimal subtree at v i with j cuts */ CCCost[1 : n, 1 : k] 0; /* S[i, j] = The set of edges to remove for the subtree v i with j cuts */ S[1 : n, 1 : k] ; for i [max(dist(v, v 1 ), 0] do for v V where v is distance i from v 1 do for j [0 : k] do Cost(v,j); return S [1,k]; 8 of 11
9 Function Cost(v,k) if v is a leaf or k = 0 then S[v, k] ; CCost[v, k] w(v); T Cost[v, k] w(v); return w (v); if left-child(v) is null then a max (w(v), T Cost[right-child(v), k 1]); b max (w(v) + CCost[right-child(v), k], T Cost[right-child(v), k]); if a<b then S[v, k] S[right-child(v), k 1] {right-edge(v)}; CCost[v, k] w(v); T Cost[v, k] a; S[v, k] S[right-child(v), k]; CCost[v, k] w(v) + CCost[right-child(v), k]; T Cost[v, k] b; if right-child(v) is null then a max (w(v), T Cost[left-child(v), k 1]); b max (w(v) + CCost[left-child(v), k], T Cost[left-child(v), k]); if a<b then S[v, k] S[left-child(v), k 1] {left-edge(v)}; CCost[v, k] w(v); T Cost[v, k] a; S[v, k] S[left-child(v), k]; CCost[v, k] w(v) + CCost[left-child(v), k]; T Cost[v, k] b; InteriorNode(v,k); 9 of 11
10 Function InteriorNode(v,k) /* Cut left edge */ a[0 : k 1] 0; for i [0 : k 1] do a[i] max( w (v)+ccost[right-child(v),k-i-1] TCost[left-child(v),i] TCost[right-child(v),k-i-1]); /* Cut right edge */ b[0 : k 1] 0; for i [0 : k 1] do b[i] max( w (v)+ccost[left-child(v),k-i-1] TCost[right-child(v),i] TCost[left-child(v),k-i-1]); /* Cut neither edge */ c[0 : k] 0; for i [0 : k] do c[i] max( w (v)+ccost[right-child(v),k-i]+ccost[left-child(v),i] TCost[left-child(v),i] TCost[right-child(v),k-i]); /* Cut both edges */ d[0 : k 2] 0; for i [0 : k 2] do d[i] max( w (v) TCost[left-child(v),i] TCost[right-child(v),k-i-2]); if min (a) = min (a, b, c, d) then i argmin (a); S[v, k] S[left-child(v), i] S[right-child(v), k i 1] {left-edge(v)}; CCost[v, k] w(v) + CCost[right-child(v), k i 1]; T Cost[v, k] min (a); if min (b) = min (a, b, c, d) then i argmin (b); S[v, k] S[right-child(v), i] S[left-child(v), k i 1] {right-edge(v)}; CCost[v, k] w(v) + CCost[left-child(v), k i 1]; T Cost[v, k] min (b); if min (c) = min (a, b, c, d) then i argmin (c); S[v, k] S[left-child(v), i] S[right-child(v), k i]; CCost[v, k] w(v) + CCost[right-child(v), k i] + CCost[left-child(v), i]; T Cost[v, k] min (c); if min (d) = min (a, b, c, d) then i argmin (d); S[v, k] S[left-child(v), i] S[right-child(v), k i 2] {left-edge(v), right-edge(v)}; CCost[v, k] w(v); T Cost[v, k] min (d); 10 of 11
11 5 Problem 5 input : Strings A = a 1...a m and B = b 1...b n output: Minimum cost conversion from A to B M[0 : m, 0 : n] 0 /* M[i, j] = the cost of converting a i...a m to b j...b n */; for i [m 1, m 2,..., 0] do M[i, n] M[i + 1, n] + 3; for j [n 1, n 2,..., 0] do M[m, j] M[m, j + 1] + 5; for i [m 1, m 2,..., 0] do for j [n 1, n 2,..., 0] do if a i = a j then M[i, j] M[i + 1, j + 1]; M[i, j] min (3 + M[i + 1, j], 5 + M[i, j + 1], 7 + M[i + 1, j + 1]); i 0; j 0; while i < m or j < n do if j < n and A[i, j] = 5 + M[i, j + 1] then Print(Insert b j ); if i < m and A[i, j] = 3 + M[i + 1, j] then Print(Delete a i ); if A[i, j] = M[i + 1, j + 1] then Print(Leave a i unchanged); i j + 1; Print(Replace a i with b j ); i j + 1; 11 of 11
Dynamic programming II - The Recursion Strikes Back
Chapter 5 Dynamic programming II - The Recursion Strikes Back By Sariel Har-Peled, December 17, 2012 1 Version: 0.4 No, mademoiselle, I don t capture elephants. I content myself with living among them.
More informationRobert Collins CSE586 CSE 586, Spring 2009 Advanced Computer Vision
CSE 586, Spring 2009 Advanced Computer Vision Dynamic Programming Decision Sequences Let D be a decision sequence {d1,d2,,dn}. (e.g. in a shortest path problem, d1 is the start node, d2 is the second node
More informationCSE 4/531 Solution 3
CSE 4/531 Solution 3 Edited by Le Fang November 7, 2017 Problem 1 M is a given n n matrix and we want to find a longest sequence S from elements of M such that the indexes of elements in M increase and
More informationOptimization II: Dynamic Programming
Chapter 12 Optimization II: Dynamic Programming In the last chapter, we saw that greedy algorithms are efficient solutions to certain optimization problems. However, there are optimization problems for
More informationLecture 5: Dynamic Programming II
Lecture 5: Dynamic Programming II Scribe: Weiyao Wang September 12, 2017 1 Lecture Overview Today s lecture continued to discuss dynamic programming techniques, and contained three parts. First, we will
More informationCSE 417 Dynamic Programming (pt 4) Sub-problems on Trees
CSE 417 Dynamic Programming (pt 4) Sub-problems on Trees Reminders > HW4 is due today > HW5 will be posted shortly Dynamic Programming Review > Apply the steps... 1. Describe solution in terms of solution
More informationCSL 730: Parallel Programming. Algorithms
CSL 73: Parallel Programming Algorithms First 1 problem Input: n-bit vector Output: minimum index of a 1-bit First 1 problem Input: n-bit vector Output: minimum index of a 1-bit Algorithm: Divide into
More informationGreedy Algorithms CSE 780
Greedy Algorithms CSE 780 Reading: Sections 16.1, 16.2, 16.3, Chapter 23. 1 Introduction Optimization Problem: Construct a sequence or a set of elements {x 1,..., x k } that satisfies given constraints
More informationCOS 226 Algorithms and Data Structures Fall Final Solutions. 10. Remark: this is essentially the same question from the midterm.
COS 226 Algorithms and Data Structures Fall 2011 Final Solutions 1 Analysis of algorithms (a) T (N) = 1 10 N 5/3 When N increases by a factor of 8, the memory usage increases by a factor of 32 Thus, T
More informationCSL 730: Parallel Programming
CSL 73: Parallel Programming General Algorithmic Techniques Balance binary tree Partitioning Divid and conquer Fractional cascading Recursive doubling Symmetry breaking Pipelining 2 PARALLEL ALGORITHM
More informationWe ve done. Now. Next
We ve done Matroid Theory Task scheduling problem (another matroid example) Dijkstra s algorithm (another greedy example) Dynamic Programming Now Matrix Chain Multiplication Longest Common Subsequence
More informationCSE 417 Dynamic Programming (pt 5) Multiple Inputs
CSE 417 Dynamic Programming (pt 5) Multiple Inputs Reminders > HW5 due Wednesday Dynamic Programming Review > Apply the steps... optimal substructure: (small) set of solutions, constructed from solutions
More informationUnit 4: Dynamic Programming
Unit 4: Dynamic Programming Course contents: Assembly-line scheduling Matrix-chain multiplication Longest common subsequence Optimal binary search trees Applications: Cell flipping, rod cutting, optimal
More informationProgramming Priority Queue
SE-286: Data Structures and Programming g Priority Queue Virendra Singh Indian Institute of Science Bangalore Lecture 18 Courtesy: Prof. Sartaj Sahni Oct 4, 2010 1 Priority Queues Two kinds of priority
More informationGreedy Algorithms CSE 6331
Greedy Algorithms CSE 6331 Reading: Sections 16.1, 16.2, 16.3, Chapter 23. 1 Introduction Optimization Problem: Construct a sequence or a set of elements {x 1,..., x k } that satisfies given constraints
More informationAlgorithms: COMP3121/3821/9101/9801
NEW SOUTH WALES Algorithms: COMP3121/3821/9101/9801 Aleks Ignjatović School of Computer Science and Engineering University of New South Wales TOPIC 5: DYNAMIC PROGRAMMING COMP3121/3821/9101/9801 1 / 38
More informationSteven Skiena. skiena
Lecture 12: Examples of Dynamic Programming (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Give an O(n 2 )
More informationOptimal Region for Binary Search Tree, Rotation and Polytope
Optimal Region for Binary Search Tree, Rotation and Polytope Kensuke Onishi Mamoru Hoshi 2 Department of Mathematical Sciences, School of Science Tokai University, 7 Kitakaname, Hiratsuka, Kanagawa, 259-292,
More informationModule 16: Data Flow Analysis in Presence of Procedure Calls Lecture 32: Iteration. The Lecture Contains: Iteration Space.
The Lecture Contains: Iteration Space Iteration Vector Normalized Iteration Vector Dependence Distance Direction Vector Loop Carried Dependence Relations Dependence Level Iteration Vector - Triangular
More informationCSL 860: Modern Parallel
CSL 860: Modern Parallel Computation PARALLEL ALGORITHM TECHNIQUES: BALANCED BINARY TREE Reduction n operands => log n steps Total work = O(n) How do you map? Balance Binary tree technique Reduction n
More informationLecture 4: Dynamic programming I
Lecture : Dynamic programming I Dynamic programming is a powerful, tabular method that solves problems by combining solutions to subproblems. It was introduced by Bellman in the 950 s (when programming
More informationAlgorithms: Dynamic Programming
Algorithms: Dynamic Programming Amotz Bar-Noy CUNY Spring 2012 Amotz Bar-Noy (CUNY) Dynamic Programming Spring 2012 1 / 58 Dynamic Programming General Strategy: Solve recursively the problem top-down based
More informationIf the retrieving probability is equal for all programs, the Mean of Retrieval Time will be
.. The optimal storage tape: In this problem, the number of programs is N, the tape length is L, the length of the program LP j = P j, the programs will be stored in the sequence P, P,, P N, to retrieve
More informationLecturers: Sanjam Garg and Prasad Raghavendra March 20, Midterm 2 Solutions
U.C. Berkeley CS70 : Algorithms Midterm 2 Solutions Lecturers: Sanjam Garg and Prasad aghavra March 20, 207 Midterm 2 Solutions. (0 points) True/False Clearly put your answers in the answer box in front
More information6.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 informationS. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani 165
S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani 165 5.22. You are given a graph G = (V, E) with positive edge weights, and a minimum spanning tree T = (V, E ) with respect to these weights; you may
More informationDEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-III. SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks)
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-III SUB CODE: CS2251 DEPT: CSE SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks) 1. Write any four examples
More informationNET/JRF-COMPUTER SCIENCE & APPLICATIONS. Time: 01 : 00 Hour Date : M.M. : 50
1 NET/JRF-COMPUTER SCIENCE & APPLICATIONS UNIT TEST : DATA STRUCTURE Time: 01 : 00 Hour Date : 02-06-2017 M.M. : 50 INSTRUCTION: Attempt all the 25 questions. Each question carry TWO marks. 1. Consider
More informationBinary Heaps in Dynamic Arrays
Yufei Tao ITEE University of Queensland We have already learned that the binary heap serves as an efficient implementation of a priority queue. Our previous discussion was based on pointers (for getting
More informationDijkstra s Algorithm. Dijkstra s algorithm is a natural, greedy approach towards
CPSC-320: Intermediate Algorithm Design and Analysis 128 CPSC-320: Intermediate Algorithm Design and Analysis 129 Dijkstra s Algorithm Dijkstra s algorithm is a natural, greedy approach towards solving
More informationGreedy Algorithms. CLRS Chapters Introduction to greedy algorithms. Design of data-compression (Huffman) codes
Greedy Algorithms CLRS Chapters 16.1 16.3 Introduction to greedy algorithms Activity-selection problem Design of data-compression (Huffman) codes (Minimum spanning tree problem) (Shortest-path problem)
More informationUNIT III TREES. A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items.
UNIT III TREES A tree is a non-linear data structure that is used to represents hierarchical relationships between individual data items. Tree: A tree is a finite set of one or more nodes such that, there
More informationHere we illustrate the Java Execution Model in the context of some sample programs. Void Methods Without Parameters: StitchWorld
JEM Examples Here we illustrate the Java Execution Model in the context of some sample programs. Void Methods Without Parameters: As a first example, we consider the example in figure 1. The class is a
More informationIntroduction to Algorithms and Data Structures. Lecture 12: Sorting (3) Quick sort, complexity of sort algorithms, and counting sort
Introduction to Algorithms and Data Structures Lecture 12: Sorting (3) Quick sort, complexity of sort algorithms, and counting sort Professor Ryuhei Uehara, School of Information Science, JAIST, Japan.
More informationCSE 4500 (228) Fall 2010 Selected Notes Set 2
CSE 4500 (228) Fall 2010 Selected Notes Set 2 Alexander A. Shvartsman Computer Science and Engineering University of Connecticut Copyright c 2002-2010 by Alexander A. Shvartsman. All rights reserved. 2
More informationParallel Programming. Easy Cases: Data Parallelism
Parallel Programming The preferred parallel algorithm is generally different from the preferred sequential algorithm Compilers cannot transform a sequential algorithm into a parallel one with adequate
More informationCSE 548: Analysis of Algorithms. Lectures 14 & 15 ( Dijkstra s SSSP & Fibonacci Heaps )
CSE 548: Analysis of Algorithms Lectures 14 & 15 ( Dijkstra s SSSP & Fibonacci Heaps ) Rezaul A. Chowdhury Department of Computer Science SUNY Stony Brook Fall 2012 Fibonacci Heaps ( Fredman & Tarjan,
More informationDynamic Programming Homework Problems
CS 1510 Dynamic Programming Homework Problems 1. Consider the recurrence relation T(0) = T(1) = 2 and for n > 1 n 1 T(n) = T(i)T(i 1) i=1 We consider the problem of computing T(n) from n. (a) Show that
More informationAlgorithms ~ R-ES-O-N-A-N--C-E-I-A-U-9-U-st Algorithm Design Techniques.
Algorithms 8. Algorithm Design Techniques R K Shyamasundar This article continues with the exploration of common algorithm design techniques. In particular, we discuss balancing, greedy strategy, backtracking
More informationCode Generation. M.B.Chandak Lecture notes on Language Processing
Code Generation M.B.Chandak Lecture notes on Language Processing Code Generation It is final phase of compilation. Input from ICG and output in the form of machine code of target machine. Major issues
More information10. EXTENDING TRACTABILITY
0. EXTENDING TRACTABILITY finding small vertex covers solving NP-hard problems on trees circular arc coverings vertex cover in bipartite graphs Lecture slides by Kevin Wayne Copyright 005 Pearson-Addison
More information1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors
1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors on an EREW PRAM: See solution for the next problem. Omit the step where each processor sequentially computes the AND of
More informationGraph Algorithms. Definition
Graph Algorithms Many problems in CS can be modeled as graph problems. Algorithms for solving graph problems are fundamental to the field of algorithm design. Definition A graph G = (V, E) consists of
More informationCSE 5311 Notes 4a: Priority Queues
Chart on p., CLRS (binary, Fibonacci heaps) CSE Notes a: Priority Queues (Last updated 9// : AM) MAKE-HEAP INSERT MINIMUM EXTRACT-MIN UNION (MELD/MERGE) DECREASE-KEY DELETE Applications - sorting (?),
More informationConvex Polygon Generation
Convex Polygon Generation critterai.org /projects/nmgen_study/polygen.html This page describes the forth stage in building a navigation mesh, the generation of convex polygons from the simple polygons
More informationCS 200 Algorithms and Data Structures, Fall 2012 Programming Assignment #3
Compressing Data using Huffman Coding Due Oct.24 noon Objectives In this assignment, you will implement classes for data compression. You will write: () An implementation of the Huffman Coding using a
More informationCSE 373 Spring Midterm. Friday April 21st
CSE 373 Spring 2006 Data Structures and Algorithms Midterm Friday April 21st NAME : Do all your work on these pages. Do not add any pages. Use back pages if necessary. Show your work to get partial credit.
More informationHomework Assignment #3
CS 540-2: Introduction to Artificial Intelligence Homework Assignment #3 Assigned: Monday, February 20 Due: Saturday, March 4 Hand-In Instructions This assignment includes written problems and programming
More informationCS 361 Data Structures & Algs Lecture 11. Prof. Tom Hayes University of New Mexico
CS 361 Data Structures & Algs Lecture 11 Prof. Tom Hayes University of New Mexico 09-28-2010 1 Last Time Priority Queues & Heaps Heapify (up and down) 1: Preserve shape of tree 2: Swaps restore heap order
More informationDynamic Programming Homework Problems
CS 1510 Dynamic Programming Homework Problems 1. (2 points) Consider the recurrence relation T (0) = T (1) = 2 and for n > 1 n 1 T (n) = T (i)t (i 1) i=1 We consider the problem of computing T (n) from
More informationData Structures and Algorithms Chapter 2
1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples
More informationPriority Queues. Priority Queue Specification. Priority Queue ADT. Implementation #1
Priority Queues A Greedy Approximation Algorithm for Computing Shortest Superstrings Lecture 13 Riley 7.9, 9.1-9.3 Cormen et al. parts of 11 Priority Queues A queue in which all items are assigned a priority
More informationAnalyze the obvious algorithm, 5 points Here is the most obvious algorithm for this problem: (LastLargerElement[A[1..n]:
CSE 101 Homework 1 Background (Order and Recurrence Relations), correctness proofs, time analysis, and speeding up algorithms with restructuring, preprocessing and data structures. Due Thursday, April
More informationData Dependence Analysis
CSc 553 Principles of Compilation 33 : Loop Dependence Data Dependence Analysis Department of Computer Science University of Arizona collberg@gmail.com Copyright c 2011 Christian Collberg Data Dependence
More information14 Dynamic. Matrix-chain multiplication. P.D. Dr. Alexander Souza. Winter term 11/12
Algorithms Theory 14 Dynamic Programming (2) Matrix-chain multiplication P.D. Dr. Alexander Souza Optimal substructure Dynamic programming is typically applied to optimization problems. An optimal solution
More informationHappy Endings for Flip Graphs. David Eppstein Univ. of California, Irvine Computer Science Department
Happy Endings for Flip Graphs David Eppstein Univ. of California, Irvine Computer Science Department Rotation in binary trees Rearrange links in and out of two adjacent nodes while preserving in-order
More informationWORM COLORINGS. Wayne Goddard. Dept of Mathematical Sciences, Clemson University Kirsti Wash
1 2 Discussiones Mathematicae Graph Theory xx (xxxx) 1 14 3 4 5 6 7 8 9 10 11 12 13 WORM COLORINGS Wayne Goddard Dept of Mathematical Sciences, Clemson University e-mail: goddard@clemson.edu Kirsti Wash
More informationChapter 6 Heapsort 1
Chapter 6 Heapsort 1 Introduce Heap About this lecture Shape Property and Heap Property Heap Operations Heapsort: Use Heap to Sort Fixing heap property for all nodes Use Array to represent Heap Introduce
More informationl Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are:
DDS-Heaps 1 Heaps - basics l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are: l insert an object, find the object of minimum key (find
More informationAn introduction to random forests
An introduction to random forests Eric Debreuve / Team Morpheme Institutions: University Nice Sophia Antipolis / CNRS / Inria Labs: I3S / Inria CRI SA-M / ibv Outline Machine learning Decision tree Random
More information******** Chapter-4 Dynamic programming
repeat end SHORT - PATHS Overall run time of algorithm is O ((n+ E ) log n) Example: ******** Chapter-4 Dynamic programming 4.1 The General Method Dynamic Programming: is an algorithm design method that
More informationReadings. Priority Queue ADT. FindMin Problem. Priority Queues & Binary Heaps. List implementation of a Priority Queue
Readings Priority Queues & Binary Heaps Chapter Section.-. CSE Data Structures Winter 00 Binary Heaps FindMin Problem Quickly find the smallest (or highest priority) item in a set Applications: Operating
More informationCOL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:
Name: Entry number: There are 6 questions for a total of 75 points. 1. Consider functions f(n) = 10n2 n + 3 n and g(n) = n3 n. Answer the following: (a) ( 1 / 2 point) State true or false: f(n) is O(g(n)).
More informationAlgorithms and Data Structures for Mathematicians
Algorithms and Data Structures for Mathematicians Lecture 5: Sorting Peter Kostolányi kostolanyi at fmph and so on Room M-258 26 October 2017 Sorting Algorithms Covered So Far Worst-case time complexity
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 7 April 15, 2015 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 7 April 15, 2015 洪國寶 1 Course information (5/5) Grading (Tentative) Homework 25% (You may collaborate when solving the homework, however when writing
More informationl So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible.
DDS-Heaps 1 Heaps - basics l Heaps an abstract structure where each object has a key value (the priority), and the operations are: insert an object, find the object of minimum key (find min), and delete
More informationThe Polyhedral Model (Transformations)
The Polyhedral Model (Transformations) Announcements HW4 is due Wednesday February 22 th Project proposal is due NEXT Friday, extension so that example with tool is possible (see resources website for
More informationCSE 143 Lecture 19. Binary Trees. read slides created by Marty Stepp
CSE 143 Lecture 19 Binary Trees read 17.1-17.2 slides created by Marty Stepp http://www.cs.washington.edu/143/ Trees tree: A directed, acyclic structure of linked nodes. directed : Has one-way links between
More informationDynamic Programming. December 15, CMPE 250 Dynamic Programming December 15, / 60
Dynamic Programming December 15, 2016 CMPE 250 Dynamic Programming December 15, 2016 1 / 60 Why Dynamic Programming Often recursive algorithms solve fairly difficult problems efficiently BUT in other cases
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 Let and
More informationAlgorithms Assignment 3 Solutions
Algorithms Assignment 3 Solutions 1. There is a row of n items, numbered from 1 to n. Each item has an integer value: item i has value A[i], where A[1..n] is an array. You wish to pick some of the items
More informationArrays, Vectors Searching, Sorting
Arrays, Vectors Searching, Sorting Arrays char s[200]; //array of 200 characters different type than class string can be accessed as s[0], s[1],..., s[199] s[0]= H ; s[1]= e ; s[2]= l ; s[3]= l ; s[4]=
More informationTrees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington
Trees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington 1 Trees Trees are a natural data structure for representing specific data. Family trees. Organizational
More informationTrees, Trees and More Trees
Trees, Trees and More Trees August 9, 01 Andrew B. Kahng abk@cs.ucsd.edu http://vlsicad.ucsd.edu/~abk/ How You ll See Trees in CS Trees as mathematical objects Trees as data structures Trees as tools for
More informationAlgorithms, Spring 2014, CSE, OSU Lecture 2: Sorting
6331 - Algorithms, Spring 2014, CSE, OSU Lecture 2: Sorting Instructor: Anastasios Sidiropoulos January 10, 2014 Sorting Given an array of integers A[1... n], rearrange its elements so that A[1] A[2]...
More informationD. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.
CSE 0 Name Test Fall 00 Last Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to convert an array, with priorities stored at subscripts through n,
More informationDynamic Programming (Binomial Coefficient) 1) A binomial coefficient C(n, k) can be defined as the coefficient of X^k in the expansion of (1 + X)^n. 2) A binomial coefficient C(n, k) also gives the number
More informationModule 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm
Module 27: Chained Matrix Multiplication and Bellman-Ford Shortest Path Algorithm This module 27 focuses on introducing dynamic programming design strategy and applying it to problems like chained matrix
More informationAlgorithm Design Techniques. Hwansoo Han
Algorithm Design Techniques Hwansoo Han Algorithm Design General techniques to yield effective algorithms Divide-and-Conquer Dynamic programming Greedy techniques Backtracking Local search 2 Divide-and-Conquer
More information15.Dynamic Programming
15.Dynamic Programming Dynamic Programming is an algorithm design technique for optimization problems: often minimizing or maximizing. Like divide and conquer, DP solves problems by combining solutions
More informationLecture 8. Dynamic Programming
Lecture 8. Dynamic Programming 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 informationModule 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.
The Lecture Contains: Index structure Binary search tree (BST) B-tree B+-tree Order file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture13/13_1.htm[6/14/2012
More information1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18
CS 124 Quiz 2 Review 3/25/18 1 Format You will have 83 minutes to complete the exam. The exam may have true/false questions, multiple choice, example/counterexample problems, run-this-algorithm problems,
More informationSearch Trees. Data and File Structures Laboratory. DFS Lab (ISI) Search Trees 1 / 17
Search Trees Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2017/index.html DFS Lab (ISI) Search Trees 1 / 17 Binary search trees. Definition. Binary tree in which following property
More informationBinary Heaps. CSE 373 Data Structures Lecture 11
Binary Heaps CSE Data Structures Lecture Readings and References Reading Sections.1-. //0 Binary Heaps - Lecture A New Problem Application: Find the smallest ( or highest priority) item quickly Operating
More informationCSC Design and Analysis of Algorithms. Lecture 6. Divide and Conquer Algorithm Design Technique. Divide-and-Conquer
CSC 8301- Design and Analysis of Algorithms Lecture 6 Divide and Conuer Algorithm Design Techniue Divide-and-Conuer The most-well known algorithm design strategy: 1. Divide a problem instance into two
More informationSuffix Trees and Arrays
Suffix Trees and Arrays Yufei Tao KAIST May 1, 2013 We will discuss the following substring matching problem: Problem (Substring Matching) Let σ be a single string of n characters. Given a query string
More informationHonors Algorithms Lecture: Dynamic Programming
Honors Algorithms Lecture: Dynamic Programming Julian Panetta (julian.panetta@gmail.com), based on material from Alan Siegel September 26, 2011 Note: We covered up through 6.3 in class. I fixed the errors
More informationPriority Queues and Binary Heaps
Yufei Tao ITEE University of Queensland In this lecture, we will learn our first tree data structure called the binary heap which serves as an implementation of the priority queue. Priority Queue A priority
More informationRecall: Properties of B-Trees
CSE 326 Lecture 10: B-Trees and Heaps It s lunch time what s cookin? B-Trees Insert/Delete Examples and Run Time Analysis Summary of Search Trees Introduction to Heaps and Priority Queues Covered in Chapters
More information/463 Algorithms - Fall 2013 Solution to Assignment 3
600.363/463 Algorithms - Fall 2013 Solution to Assignment 3 (120 points) I (30 points) (Hint: This problem is similar to parenthesization in matrix-chain multiplication, except the special treatment on
More informationCSE 21 Spring 2016 Homework 4 Answer Key
1 CSE 21 Spring 2016 Homework 4 Answer Key 1. In each situation, write a recurrence relation, including base case(s), that describes the recursive structure of the problem. You do not need to solve the
More informationA Comparison of Data Structures for Dijkstra's Single Source Shortest Path Algorithm. Shane Saunders
A Comparison of Data Structures for Dijkstra's Single Source Shortest Path Algorithm Shane Saunders November 5, 1999 Abstract Dijkstra's algorithm computes the shortest paths between a starting vertex
More informationData Structures Lecture 7
Fall 2017 Fang Yu Software Security Lab. Dept. Management Information Systems, National Chengchi University Data Structures Lecture 7 Recap We have talked about object oriented programing Chapter 1, 2,
More informationCS Algorithms and Complexity
CS 350 - Algorithms and Complexity Dynamic Programming Sean Anderson 2/20/18 Portland State University Table of contents 1. Homework 3 Solutions 2. Dynamic Programming 3. Problem of the Day 4. Application
More informationTheory of Computing. Lecture 4/5 MAS 714 Hartmut Klauck
Theory of Computing Lecture 4/5 MAS 714 Hartmut Klauck How fast can we sort? There are deterministic algorithms that sort in worst case time O(n log n) Do better algorithms exist? Example [Andersson et
More informationAssignment 8 Solution
McGill University COMP360 Winter 2011 Instructor: Phuong Nguyen Assignment 8 Solution Question 1 (10pt) You are given a color picture consisting of an m n array A of pixels, where each pixel specifies
More informationLecture 5 Using Data Structures to Improve Dijkstra s Algorithm. (AM&O Sections and Appendix A)
Lecture Using Data Structures to Improve Dijkstra s Algorithm (AM&O Sections 4.6 4.8 and Appendix A) Manipulating the Data in Dijkstra s Algorithm The bottleneck operation in Dijkstra s Algorithm is that
More informationCSE 417 Network Flows (pt 4) Min Cost Flows
CSE 417 Network Flows (pt 4) Min Cost Flows Reminders > HW6 is due Monday Review of last three lectures > Defined the maximum flow problem find the feasible flow of maximum value flow is feasible if it
More informationChapter 2 QUIZ. Section 2.1 The Parallel Postulate and Special Angles
Chapter 2 QUIZ Section 2.1 The Parallel Postulate and Special Angles (1.) How many lines can be drawn through point P that are parallel to line? (2.) Lines and m are cut by transversal t. Which angle corresponds
More information