CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 11: MST

Size: px
Start display at page:

Download "CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 11: MST"

Transcription

1 CSE 101 Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 11: MST

2 GREEDY-STAYS-AHEAD In this proof technique, let s revisit the original event scheduling problem. We want to show that at every step the greedy solution stays ahead of any other solution. Let O = [E j1,, E jm ] be any optimal solution and Let A = [E i1,, E ik ] be a solution returned using the greedy algorithm. We wish to show that k = m.

3 GREEDY-STAYS-AHEAD Let O = [E j1,, E jm ] be any optimal solution and Let A = [E i1,, E ik ] be a solution returned using the greedy algorithm. The greedy method guarantees that:

4 GREEDY-STAYS-AHEAD Let O = [E j1,, E jm ] be any optimal solution (ordered by finish time.) Let A = [E i1,, E ik ] be a solution returned using the greedy algorithm. The greedy method guarantees that: f(i 1 ) f(j 1 ) We want to show that for all indices r k that: f(i r ) f(j r ) (page ) Algorithm Design by Kleinberg and Tardos

5 GREEDY-STAYS-AHEAD Let O = [E j1,, E jm ] be any optimal solution (ordered by finish time.) Let A = [E i1,, E ik ] be a solution returned using the greedy algorithm. To demonstrate using proof by contradiction, assume that m > k Then we can show that since f i k f j k, for event E jk+1 we havef i k f(j k ) s j k+1, so the greedy strategy would pick E jk+1 after E ik, contradicting the fact that the greedy strategy only output k events. Therefore m = k and the greedy strategy is optimal.

6 SPANNING TREES A spanning tree of an undirected graph G=(V,E) is a subgraph G =(V,E ) such that G is a tree and all vertices in V are connected. An output tree of DFS or BFS is a spanning tree.

7 EXAMPLE Suppose you have a network of computers that were linked pairwise Suppose each link has a positive maintenance cost. Your job is to cut some links so that the cost of the network is minimized and the network stays connected.

8 EXAMPLE 1. The minimized network must be a tree 2. removing a cycle edge does not disconnect a graph

9 THE MINIMIZED GRAPH IS A TREE Proof: Suppose by contradiction that the subgraph with minimum weight that is still connected was not a tree. Then there would exist a cycle somewhere in the subgraph. Removing a cycle edge does not disconnect a graph. Each edge has a positive weight value so removing any cycle edge will not disconnect the graph and decrease the total weight contradicting the original claim.

10 EXAMPLE This subgraph has a cost of 12. Is this the minimum cost?

11 EXAMPLE Let s try a greedy approach Is this the minimum cost?

12 KRUSKAL S ALGORITHM FOR FINDING THE MINIMUM SPANNING TREE Start with a graph with only the vertices. Repeatedly add the next lightest edge that does not form a cycle.

13 CORRECTNESS OF KRUSKAL S cut property. Suppose G = V, T is a MST of G = V, E and suppose that X T. Pick any subset of vertices S V such that there is no path from S to V S using edges from X. Let e E be the lightest edge that connect S to V S. Then: X {e} is part of some MST.

14 PROOF OF CUT PROPERTY Case 1: e T Then, X {e} T and we assumed that T is the set of edges of an MST so X {e} is part of that MST.

15 PROOF OF CUT PROPERTY Case 1: e T Then, X {e} T and we assumed that T is the set of edges of an MST so X {e} is part of that MST. Case 2: e T Consider T {e}. Since T is the edge set of a connected tree, T {e} is the edgeset of a graph that has a cycle. Furthermore, the cycle contains e.

16 PROOF OF CUT PROPERTY Case 2: e T (continued ) Consider T {e}. Since T is the edge set of a connected tree, T {e} is the edgeset of a graph that has a cycle. Furthermore, the cycle contains e. there must be another edge e T that connects S to V S. Consider the edgeset T e {e }. This is still a tree.

17 PROOF OF CUT PROPERTY cost T e {e } = cost T + w e w e w e w e 0 w e w e cost T e {e } cost T But T is the edgeset of an MST so it is minimal. Therefore cost T e {e } must be minimal also and we have that cost T e {e } = cost T so T e {e } is the edgeset of an MST. X e T e {e }

18 FACTS ABOUT TREES Definition: A tree is an undirected connected graph with no cycles. An undirected connected graph is a tree if and only if removing any edge results in two disconnected graphs. An undirected connected graph with n vertices is a tree if and only if it has n -1 edges. An undirected connected graph is a tree if and only if there is a unique path between nodes

19 FACTS ABOUT TREES (PROOFS) Theorem: An undirected connected graph is a tree if and only if removing any edge results in two disconnected graphs.

20 FACTS ABOUT TREES (PROOFS) Theorem: An undirected connected graph is a tree if and only if removing any edge results in two disconnected graphs. proof: Suppose by contradiction, I can remove an edge, say (u,v), and have the graph stay connected, Then after removing the edge, there must still be a path P from v to u because the resulting graph is still connected. But in the original graph, P+(u,v) is a cycle. Contradicting the fact that the graph is a tree.

21 FACTS ABOUT TREES An undirected connected graph with n vertices is a tree if and only if it has n -1 edges.

22 FACTS ABOUT TREES An undirected connected graph with n vertices is a tree if and only if it has n -1 edges. proof(=>): Suppose a graph with n vertices is a tree. Then if we remove an edge, the resulting graph will be broken into two disconnected trees. repeatedly remove edges one by one from the graph and at each removal, the resulting graph will add one more connected component. Do this until the graph has n isolated vertices and no edges. This took n-1 many steps. So the graph must have had n-1 edges to start with.

23 FACTS ABOUT TREES An undirected connected graph with n vertices is a tree if and only if it has n -1 edges. proof(<=): Suppose an undirected connected graph G has exactly n-1 edges. By contradiction, suppose G is not a tree and thus has a cycle. While G contains a cycle, repeatedly remove a cycle edge until G is acyclic. Then the resulting graph is a tree and thus has n-1 edges. But the graph had n-1 edges to start with so no edges were removed and therefore the graph was a tree all along!!!!!

24 FACTS ABOUT TREES An undirected connected graph is a tree if and only if there is a unique path between nodes.

25 FACTS ABOUT TREES An undirected connected graph is a tree if and only if there is a unique path between nodes. proof:(=>) Suppose G is a tree. Then since it is connected, there is a path between each node. Suppose by contradiction that there exists a pair of nodes, u,v; such that there are two paths from u to v, namely P1 and P2. Then P1+reverse(P2) is a cycle, contradicting the fact that G is a tree.

26 FACTS ABOUT TREES An undirected connected graph is a tree if and only if there is a unique path between nodes. proof:(<=) Suppose there is a unique path between any two nodes in an undirected connected graph G. Suppose by contradiction that G is not a tree Then G has a cycle: v0,v1,,vk,v0 Then there is a path from v0 to vk by going through v1,v2, There is also an edge from v0 to vk. Therefore there are two distinct paths between v0 and vk.

27 KRUSKAL S ALGORITHM FOR FINDING THE MINIMUM SPANNING TREE Start with a graph with only the vertices. Repeatedly add the next lightest edge that does not form a cycle.

28 HOW TO IMPLEMENT KRUSKAL S How do we efficiently tell if adding an edge will create a cycle?

29 HOW TO IMPLEMENT KRUSKAL S How do we efficiently tell if adding an edge will create a cycle? What if we kept track of the connected components? Then if we connect two vertices in the same connected component, it will create a cycle. And if we connect two vertices in different connected components, it will not create a cycle.

30 KRUSKAL S ALGORITHM procedure kruskal(g,w) input: undirected graph G with edge weights w output: A set of edges X that defines a minimum spanning tree for all u V makeset(u) X = {} sort the edges E in increasing order by weight for all edges (u, v) E if find(u) find(v): add edge (u, v) to X union(u, v)

31 CORRECTNESS OF KRUSKAL S Loop invariant: After k iterations of the last loop, X is a subset of some MST. Proof of Loop invariant:

32 CORRECTNESS OF KRUSKAL S Loop invariant: After k iterations of the last loop, X is a subset of some MST. Proof of Loop invariant: Base case: X={} is trivially a subset of some MST Suppose after k iterations, X is a subset of some MST. Then doing one more iteration, we find the lightest edge e that does not create a cycle. That means that adding this edge to X will connect the disconnected sets S and V-S. Furthermore, this is the lightest edge connecting those sets so X {e} is a subset of some MST!!!

33 CORRECTNESS OF KRUSKAL S Loop invariant: After k iterations of the last loop, X is a subset of some MST. The algorithm terminates when all edges have been considered. No new edge will be added after X is a tree. We know that X is always a subset of some MST, so if X is a tree, it must be an MST!!!! Therefore, Kruskal s algorithm will always output a MST.

34 SUBROUTINES OF KRUSKAL S makeset (u): This creates a set with one element, u find(u): finds the set to which u belongs union(u,v): merges the sets containing u and v Runtime of Kruskal s: procedure kruskal(g,w) input: undirected graph G with edge weights w output: A set of edges X that defines a minimum spanning tree for all u V makeset(u) X = {} sort the edges E in increasing order by weight for all edges (u, v) E if find(u) find(v): add edge (u, v) to X union(u, v)

35 SUBROUTINES OF KRUSKAL S makeset (u): This creates a set with one element, u find(u): finds the set to which u belongs union(u,v): merges the sets containing u and v Runtime of Kruskal s: V makeset + 2 E find + V 1 union + sort( E )

36 EXAMPLE

37 A DATA STRUCTURE FOR KRUSKAL S (DIRECTED TREES WITH RANKS) vertices of the trees are elements of a set and each vertex points to its parent that eventually points to the root. The root points to itself. The root is a convenient representation or name of the set containing it and all of its children. in addition to the parent pointer of x, π(x), each vertex also has a rank that tells you the height of the subtree hanging from that vertex.

38 A DATA STRUCTURE FOR KRUSKAL S (DIRECTED TREES WITH RANKS)

39 A DATA STRUCTURE FOR KRUSKAL S (DIRECTED TREES WITH RANKS) rank(a)=1 rank(b)=0 rank(c)=0 rank(d)=2 rank(e)=0 rank(f)=0 rank(g)=1 π A = D π B = D π C = G π D = D π E = A π F = A π G = G

40 SUBROUTINES. procedure makeset(x) π x : = x rank(x):=0

41 SUBROUTINES. procedure find(x) while x π x x: = π x return x

42 SUBROUTINES. procedure union(x,y) rx:=find(x) ry:=find(y) if rx=ry then return if rank(rx)>rank(ry) then else π ry : = rx π ry : = rx if rank(rx)=rank(ry) then rank(ry):=rank(rx)+1 To save on runtime, we must keep the heights of the trees short. So union of two ranks points the smaller rank to the bigger rank, that way, the tree will stay the same height. If the ranks are equal, then it increments one rank and points the smaller to the bigger. (this is the only way a rank can increase.)

43 SUBROUTINES. procedure makeset(x) π x : = x rank(x):=0 procedure find(x) while x π x x: = π x return x makeset=o(1) find=o(height of tree containing x) union=o(find) procedure union(x,y) rx:=find(x) ry:=find(y) if rx=ry then return if rank(rx)>rank(ry) then else π ry : = rx π ry : = rx if rank(rx)=rank(ry) then rank(ry):=rank(rx)+1

44 EXAMPLE makeset({a,b,c,d,e,f,g}) union(a,d), union(b,e), union(b,f), union(a,g), union(d,g),union(b,d), union(c,e)

45 EXAMPLE makeset({a,b,c,d,e,f,g}) union(b,c), union(e,g), union(d,f), union(a,b), union(d,g),union(a,f)

46 EXAMPLE

47 HEIGHT OF TREE any root node of rank k has at least 2 k vertices in its tree. proof: Base Case: a root of rank 0 has 1 vertex suppose a root of rank k has at least 2 k vertices in its tree Then a root of rank k+1 can only be made by unioning 2 roots each of rank k so a root of rank k+1 must have at least 2 k + 2 k = 2 k+1 vertices in its tree.

48 ANCESTORS OF RANK K any vertex has at most one ancestor of rank k proof: each vertex has one pointer and ranks strictly increase along paths so each element has at most one ancestor of each rank.

49 NUMBER OF VERTICES OF A GIVEN RANK if there are n vertices overall, there can be at most n 2k vertices of rank k proof: each rank k vertex has at least 2 k vertices in its tree so if there are m rank k vertices then there are m2 k vertices overall. if there are n vertices overall then m2 k n so m n 2 k

50 HEIGHT OF TALLEST TREE (MAXIMUM RANK) the maximum rank is log(n) proof: (sort of) How many vertices of rank log(n) can there be?

51 HEIGHT OF TALLEST TREE (MAXIMUM RANK) the maximum rank is log(n) proof: (sort of) How many vertices of rank log(n) can there be? n = 1 2log (n) anything more is not possible.

52 RUNTIME makeset=o(1) find=o(height of tree containing x) union=o(find) makeset (u): This creates a set with one element, u find(u): finds the set to which u belongs union(u,v): merges the sets containing u and v Runtime of Kruskal s: V makeset + 2 E find + V 1 union + sort( E )

53 RUNTIME makeset=o(1) find=o(log(n)) union=o(log(n)) makeset (u): This creates a set with one element, u find(u): finds the set to which u belongs union(u,v): merges the sets containing u and v Runtime of Kruskal s: V makeset + 2 E find + V 1 union + sort( E ) V O E O log V + V 1 O log V + E log E O( V + E log V + V log V + E log E ) O E log( V )

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge,

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

More information

Solutions to Homework 6

Solutions to Homework 6 Solutions to Homework 6 Debasish Das EECS Department, Northwestern University ddas@northwestern.edu 1 Problem 5.24 We want to find light spanning trees with certain special properties. Given is one example

More information

CMPSCI611: Approximating MAX-CUT Lecture 20

CMPSCI611: Approximating MAX-CUT Lecture 20 CMPSCI611: Approximating MAX-CUT Lecture 20 For the next two lectures we ll be seeing examples of approximation algorithms for interesting NP-hard problems. Today we consider MAX-CUT, which we proved to

More information

Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014

Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014 Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li Advised by: Dave Mount May 22, 2014 1 INTRODUCTION In this report we consider the implementation of an efficient

More information

GRAPH THEORY LECTURE 4: TREES

GRAPH THEORY LECTURE 4: TREES GRAPH THEORY LECTURE 4: TREES Abstract. 3.1 presents some standard characterizations and properties of trees. 3.2 presents several different types of trees. 3.7 develops a counting method based on a bijection

More information

Motivation Suppose we have a database of people We want to gure out who is related to whom Initially, we only have a list of people, and information a

Motivation Suppose we have a database of people We want to gure out who is related to whom Initially, we only have a list of people, and information a CSE 220: Handout 29 Disjoint Sets 1 Motivation Suppose we have a database of people We want to gure out who is related to whom Initially, we only have a list of people, and information about relations

More information

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics* IE 680 Special Topics in Production Systems: Networks, Routing and Logistics* Rakesh Nagi Department of Industrial Engineering University at Buffalo (SUNY) *Lecture notes from Network Flows by Ahuja, Magnanti

More information

Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

More information

5.1 Bipartite Matching

5.1 Bipartite Matching CS787: Advanced Algorithms Lecture 5: Applications of Network Flow In the last lecture, we looked at the problem of finding the maximum flow in a graph, and how it can be efficiently solved using the Ford-Fulkerson

More information

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) 3 4 4 7 5 9 6 16 7 8 8 4 9 8 10 4 Total 92. Name: Email ID: CSE 326, Data Structures Section: Sample Final Exam Instructions: The exam is closed book, closed notes. Unless otherwise stated, N denotes the number of elements in the data structure

More information

Cpt S 223. School of EECS, WSU

Cpt S 223. School of EECS, WSU The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring

More information

Chapter 6: Graph Theory

Chapter 6: Graph Theory Chapter 6: Graph Theory Graph theory deals with routing and network problems and if it is possible to find a best route, whether that means the least expensive, least amount of time or the least distance.

More information

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010. Chapter 7: Digraphs

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010. Chapter 7: Digraphs MCS-236: Graph Theory Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, 2010 Chapter 7: Digraphs Strong Digraphs Definitions. A digraph is an ordered pair (V, E), where V is the set

More information

Problem Set 7 Solutions

Problem Set 7 Solutions 8 8 Introduction to Algorithms May 7, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Handout 25 Problem Set 7 Solutions This problem set is due in

More information

Social Media Mining. Graph Essentials

Social Media Mining. Graph Essentials Graph Essentials Graph Basics Measures Graph and Essentials Metrics 2 2 Nodes and Edges A network is a graph nodes, actors, or vertices (plural of vertex) Connections, edges or ties Edge Node Measures

More information

CIS 700: algorithms for Big Data

CIS 700: algorithms for Big Data CIS 700: algorithms for Big Data Lecture 6: Graph Sketching Slides at http://grigory.us/big-data-class.html Grigory Yaroslavtsev http://grigory.us Sketching Graphs? We know how to sketch vectors: v Mv

More information

Full and Complete Binary Trees

Full and Complete Binary Trees Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

More information

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8] Code No: R05220502 Set No. 1 1. (a) Describe the performance analysis in detail. (b) Show that f 1 (n)+f 2 (n) = 0(max(g 1 (n), g 2 (n)) where f 1 (n) = 0(g 1 (n)) and f 2 (n) = 0(g 2 (n)). [8+8] 2. (a)

More information

Connectivity and cuts

Connectivity and cuts Math 104, Graph Theory February 19, 2013 Measure of connectivity How connected are each of these graphs? > increasing connectivity > I G 1 is a tree, so it is a connected graph w/minimum # of edges. Every

More information

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation: CSE341T 08/31/2015 Lecture 3 Cost Model: Work, Span and Parallelism In this lecture, we will look at how one analyze a parallel program written using Cilk Plus. When we analyze the cost of an algorithm

More information

Data Structures Fibonacci Heaps, Amortized Analysis

Data Structures Fibonacci Heaps, Amortized Analysis Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:

More information

Near Optimal Solutions

Near Optimal Solutions Near Optimal Solutions Many important optimization problems are lacking efficient solutions. NP-Complete problems unlikely to have polynomial time solutions. Good heuristics important for such problems.

More information

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005 V. Adamchik 1 Graph Theory Victor Adamchik Fall of 2005 Plan 1. Basic Vocabulary 2. Regular graph 3. Connectivity 4. Representing Graphs Introduction A.Aho and J.Ulman acknowledge that Fundamentally, computer

More information

Lecture 10 Union-Find The union-nd data structure is motivated by Kruskal's minimum spanning tree algorithm (Algorithm 2.6), in which we needed two operations on disjoint sets of vertices: determine whether

More information

Scheduling Shop Scheduling. Tim Nieberg

Scheduling Shop Scheduling. Tim Nieberg Scheduling Shop Scheduling Tim Nieberg Shop models: General Introduction Remark: Consider non preemptive problems with regular objectives Notation Shop Problems: m machines, n jobs 1,..., n operations

More information

Lecture 17 : Equivalence and Order Relations DRAFT

Lecture 17 : Equivalence and Order Relations DRAFT CS/Math 240: Introduction to Discrete Mathematics 3/31/2011 Lecture 17 : Equivalence and Order Relations Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last lecture we introduced the notion

More information

Analysis of Algorithms, I

Analysis of Algorithms, I Analysis of Algorithms, I CSOR W4231.002 Eleni Drinea Computer Science Department Columbia University Thursday, February 26, 2015 Outline 1 Recap 2 Representing graphs 3 Breadth-first search (BFS) 4 Applications

More information

Outline 2.1 Graph Isomorphism 2.2 Automorphisms and Symmetry 2.3 Subgraphs, part 1

Outline 2.1 Graph Isomorphism 2.2 Automorphisms and Symmetry 2.3 Subgraphs, part 1 GRAPH THEORY LECTURE STRUCTURE AND REPRESENTATION PART A Abstract. Chapter focuses on the question of when two graphs are to be regarded as the same, on symmetries, and on subgraphs.. discusses the concept

More information

Any two nodes which are connected by an edge in a graph are called adjacent node.

Any two nodes which are connected by an edge in a graph are called adjacent node. . iscuss following. Graph graph G consist of a non empty set V called the set of nodes (points, vertices) of the graph, a set which is the set of edges and a mapping from the set of edges to a set of pairs

More information

5 Directed acyclic graphs

5 Directed acyclic graphs 5 Directed acyclic graphs (5.1) Introduction In many statistical studies we have prior knowledge about a temporal or causal ordering of the variables. In this chapter we will use directed graphs to incorporate

More information

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification) Some N P problems Computer scientists have studied many N P problems, that is, problems that can be solved nondeterministically in polynomial time. Traditionally complexity question are studied as languages:

More information

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Why? A central concept in Computer Science. Algorithms are ubiquitous. Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

More information

MapReduce and Distributed Data Analysis. Sergei Vassilvitskii Google Research

MapReduce and Distributed Data Analysis. Sergei Vassilvitskii Google Research MapReduce and Distributed Data Analysis Google Research 1 Dealing With Massive Data 2 2 Dealing With Massive Data Polynomial Memory Sublinear RAM Sketches External Memory Property Testing 3 3 Dealing With

More information

BALTIC OLYMPIAD IN INFORMATICS Stockholm, April 18-22, 2009 Page 1 of?? ENG rectangle. Rectangle

BALTIC OLYMPIAD IN INFORMATICS Stockholm, April 18-22, 2009 Page 1 of?? ENG rectangle. Rectangle Page 1 of?? ENG rectangle Rectangle Spoiler Solution of SQUARE For start, let s solve a similar looking easier task: find the area of the largest square. All we have to do is pick two points A and B and

More information

Part 2: Community Detection

Part 2: Community Detection Chapter 8: Graph Data Part 2: Community Detection Based on Leskovec, Rajaraman, Ullman 2014: Mining of Massive Datasets Big Data Management and Analytics Outline Community Detection - Social networks -

More information

Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

More information

International Journal of Advanced Research in Computer Science and Software Engineering

International Journal of Advanced Research in Computer Science and Software Engineering Volume 3, Issue 7, July 23 ISSN: 2277 28X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Greedy Algorithm:

More information

Union-Find Algorithms. network connectivity quick find quick union improvements applications

Union-Find Algorithms. network connectivity quick find quick union improvements applications Union-Find Algorithms network connectivity quick find quick union improvements applications 1 Subtext of today s lecture (and this course) Steps to developing a usable algorithm. Define the problem. Find

More information

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010

CS 598CSC: Combinatorial Optimization Lecture date: 2/4/2010 CS 598CSC: Combinatorial Optimization Lecture date: /4/010 Instructor: Chandra Chekuri Scribe: David Morrison Gomory-Hu Trees (The work in this section closely follows [3]) Let G = (V, E) be an undirected

More information

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits Outline NP-completeness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2-pairs sum vs. general Subset Sum Reducing one problem to another Clique

More information

A simpler and better derandomization of an approximation algorithm for Single Source Rent-or-Buy

A simpler and better derandomization of an approximation algorithm for Single Source Rent-or-Buy A simpler and better derandomization of an approximation algorithm for Single Source Rent-or-Buy David P. Williamson Anke van Zuylen School of Operations Research and Industrial Engineering, Cornell University,

More information

Graph Theory Problems and Solutions

Graph Theory Problems and Solutions raph Theory Problems and Solutions Tom Davis tomrdavis@earthlink.net http://www.geometer.org/mathcircles November, 005 Problems. Prove that the sum of the degrees of the vertices of any finite graph is

More information

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li Computer Algorithms NP-Complete Problems NP-completeness The quest for efficient algorithms is about finding clever ways to bypass the process of exhaustive search, using clues from the input in order

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm. Approximation Algorithms 11 Approximation Algorithms Q Suppose I need to solve an NP-hard problem What should I do? A Theory says you're unlikely to find a poly-time algorithm Must sacrifice one of three

More information

Triangle deletion. Ernie Croot. February 3, 2010

Triangle deletion. Ernie Croot. February 3, 2010 Triangle deletion Ernie Croot February 3, 2010 1 Introduction The purpose of this note is to give an intuitive outline of the triangle deletion theorem of Ruzsa and Szemerédi, which says that if G = (V,

More information

Every tree contains a large induced subgraph with all degrees odd

Every tree contains a large induced subgraph with all degrees odd Every tree contains a large induced subgraph with all degrees odd A.J. Radcliffe Carnegie Mellon University, Pittsburgh, PA A.D. Scott Department of Pure Mathematics and Mathematical Statistics University

More information

Tools for parsimonious edge-colouring of graphs with maximum degree three. J.L. Fouquet and J.M. Vanherpe. Rapport n o RR-2010-10

Tools for parsimonious edge-colouring of graphs with maximum degree three. J.L. Fouquet and J.M. Vanherpe. Rapport n o RR-2010-10 Tools for parsimonious edge-colouring of graphs with maximum degree three J.L. Fouquet and J.M. Vanherpe LIFO, Université d Orléans Rapport n o RR-2010-10 Tools for parsimonious edge-colouring of graphs

More information

Lecture 22: November 10

Lecture 22: November 10 CS271 Randomness & Computation Fall 2011 Lecture 22: November 10 Lecturer: Alistair Sinclair Based on scribe notes by Rafael Frongillo Disclaimer: These notes have not been subjected to the usual scrutiny

More information

CSC 505, Fall 2000: Week 8

CSC 505, Fall 2000: Week 8 Objecties: CSC 505, Fall 2000: Week 8 learn abot the basic depth-first search algorithm learn how properties of a graph can be inferred from the strctre of a DFS tree learn abot one nontriial application

More information

6.852: Distributed Algorithms Fall, 2009. Class 2

6.852: Distributed Algorithms Fall, 2009. Class 2 .8: Distributed Algorithms Fall, 009 Class Today s plan Leader election in a synchronous ring: Lower bound for comparison-based algorithms. Basic computation in general synchronous networks: Leader election

More information

arxiv:1412.2333v1 [cs.dc] 7 Dec 2014

arxiv:1412.2333v1 [cs.dc] 7 Dec 2014 Minimum-weight Spanning Tree Construction in O(log log log n) Rounds on the Congested Clique Sriram V. Pemmaraju Vivek B. Sardeshmukh Department of Computer Science, The University of Iowa, Iowa City,

More information

Midterm Practice Problems

Midterm Practice Problems 6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator

More information

Analysis of Algorithms I: Binary Search Trees

Analysis of Algorithms I: Binary Search Trees Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary

More information

SPANNING CACTI FOR STRUCTURALLY CONTROLLABLE NETWORKS NGO THI TU ANH NATIONAL UNIVERSITY OF SINGAPORE

SPANNING CACTI FOR STRUCTURALLY CONTROLLABLE NETWORKS NGO THI TU ANH NATIONAL UNIVERSITY OF SINGAPORE SPANNING CACTI FOR STRUCTURALLY CONTROLLABLE NETWORKS NGO THI TU ANH NATIONAL UNIVERSITY OF SINGAPORE 2012 SPANNING CACTI FOR STRUCTURALLY CONTROLLABLE NETWORKS NGO THI TU ANH (M.Sc., SFU, Russia) A THESIS

More information

All trees contain a large induced subgraph having all degrees 1 (mod k)

All trees contain a large induced subgraph having all degrees 1 (mod k) All trees contain a large induced subgraph having all degrees 1 (mod k) David M. Berman, A.J. Radcliffe, A.D. Scott, Hong Wang, and Larry Wargo *Department of Mathematics University of New Orleans New

More information

Network (Tree) Topology Inference Based on Prüfer Sequence

Network (Tree) Topology Inference Based on Prüfer Sequence Network (Tree) Topology Inference Based on Prüfer Sequence C. Vanniarajan and Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology Madras Chennai 600036 vanniarajanc@hcl.in,

More information

Exam study sheet for CS2711. List of topics

Exam study sheet for CS2711. List of topics Exam study sheet for CS2711 Here is the list of topics you need to know for the final exam. For each data structure listed below, make sure you can do the following: 1. Give an example of this data structure

More information

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child

Binary Search Trees. Data in each node. Larger than the data in its left child Smaller than the data in its right child Binary Search Trees Data in each node Larger than the data in its left child Smaller than the data in its right child FIGURE 11-6 Arbitrary binary tree FIGURE 11-7 Binary search tree Data Structures Using

More information

Discrete Applied Mathematics. The firefighter problem with more than one firefighter on trees

Discrete Applied Mathematics. The firefighter problem with more than one firefighter on trees Discrete Applied Mathematics 161 (2013) 899 908 Contents lists available at SciVerse ScienceDirect Discrete Applied Mathematics journal homepage: www.elsevier.com/locate/dam The firefighter problem with

More information

Institut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie. An Iterative Compression Algorithm for Vertex Cover

Institut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie. An Iterative Compression Algorithm for Vertex Cover Friedrich-Schiller-Universität Jena Institut für Informatik Lehrstuhl Theoretische Informatik I / Komplexitätstheorie Studienarbeit An Iterative Compression Algorithm for Vertex Cover von Thomas Peiselt

More information

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs

Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs CSE599s: Extremal Combinatorics November 21, 2011 Lecture 15 An Arithmetic Circuit Lowerbound and Flows in Graphs Lecturer: Anup Rao 1 An Arithmetic Circuit Lower Bound An arithmetic circuit is just like

More information

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling

Minimum cost maximum flow, Minimum cost circulation, Cost/Capacity scaling 6.854 Advanced Algorithms Lecture 16: 10/11/2006 Lecturer: David Karger Scribe: Kermin Fleming and Chris Crutchfield, based on notes by Wendy Chu and Tudor Leu Minimum cost maximum flow, Minimum cost circulation,

More information

Binary Search Trees CMPSC 122

Binary Search Trees CMPSC 122 Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than

More information

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory CSC2420 Fall 2012: Algorithm Design, Analysis and Theory Allan Borodin November 15, 2012; Lecture 10 1 / 27 Randomized online bipartite matching and the adwords problem. We briefly return to online algorithms

More information

Minimum Spanning Trees

Minimum Spanning Trees Minimum Spanning Trees weighted graph API cycles and cuts Kruskal s algorithm Prim s algorithm advanced topics References: Algorithms in Java, Chapter 20 http://www.cs.princeton.edu/introalgsds/54mst 1

More information

OPTIMAL DESIGN OF DISTRIBUTED SENSOR NETWORKS FOR FIELD RECONSTRUCTION

OPTIMAL DESIGN OF DISTRIBUTED SENSOR NETWORKS FOR FIELD RECONSTRUCTION OPTIMAL DESIGN OF DISTRIBUTED SENSOR NETWORKS FOR FIELD RECONSTRUCTION Sérgio Pequito, Stephen Kruzick, Soummya Kar, José M. F. Moura, A. Pedro Aguiar Department of Electrical and Computer Engineering

More information

1. Write the number of the left-hand item next to the item on the right that corresponds to it.

1. Write the number of the left-hand item next to the item on the right that corresponds to it. 1. Write the number of the left-hand item next to the item on the right that corresponds to it. 1. Stanford prison experiment 2. Friendster 3. neuron 4. router 5. tipping 6. small worlds 7. job-hunting

More information

Complexity of Union-Split-Find Problems. Katherine Jane Lai

Complexity of Union-Split-Find Problems. Katherine Jane Lai Complexity of Union-Split-Find Problems by Katherine Jane Lai S.B., Electrical Engineering and Computer Science, MIT, 2007 S.B., Mathematics, MIT, 2007 Submitted to the Department of Electrical Engineering

More information

Data Structure [Question Bank]

Data Structure [Question Bank] Unit I (Analysis of Algorithms) 1. What are algorithms and how they are useful? 2. Describe the factor on best algorithms depends on? 3. Differentiate: Correct & Incorrect Algorithms? 4. Write short note:

More information

Network Flow I. Lecture 16. 16.1 Overview. 16.2 The Network Flow Problem

Network Flow I. Lecture 16. 16.1 Overview. 16.2 The Network Flow Problem Lecture 6 Network Flow I 6. Overview In these next two lectures we are going to talk about an important algorithmic problem called the Network Flow Problem. Network flow is important because it can be

More information

An algorithmic classification of open surfaces

An algorithmic classification of open surfaces An algorithmic classification of open surfaces Sylvain Maillot January 8, 2013 Abstract We propose a formulation for the homeomorphism problem for open n-dimensional manifolds and use the Kerekjarto classification

More information

Helvetic Coding Contest 2016

Helvetic Coding Contest 2016 Helvetic Coding Contest 6 Solution Sketches July, 6 A Collective Mindsets Author: Christian Kauth A Strategy: In a bottom-up approach, we can determine how many brains a zombie of a given rank N needs

More information

8.1 Min Degree Spanning Tree

8.1 Min Degree Spanning Tree CS880: Approximations Algorithms Scribe: Siddharth Barman Lecturer: Shuchi Chawla Topic: Min Degree Spanning Tree Date: 02/15/07 In this lecture we give a local search based algorithm for the Min Degree

More information

Euler Paths and Euler Circuits

Euler Paths and Euler Circuits Euler Paths and Euler Circuits An Euler path is a path that uses every edge of a graph exactly once. An Euler circuit is a circuit that uses every edge of a graph exactly once. An Euler path starts and

More information

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs Kousha Etessami U. of Edinburgh, UK Kousha Etessami (U. of Edinburgh, UK) Discrete Mathematics (Chapter 6) 1 / 13 Overview Graphs and Graph

More information

Protein Protein Interaction Networks

Protein Protein Interaction Networks Functional Pattern Mining from Genome Scale Protein Protein Interaction Networks Young-Rae Cho, Ph.D. Assistant Professor Department of Computer Science Baylor University it My Definition of Bioinformatics

More information

Ordered Lists and Binary Trees

Ordered Lists and Binary Trees Data Structures and Algorithms Ordered Lists and Binary Trees Chris Brooks Department of Computer Science University of San Francisco Department of Computer Science University of San Francisco p.1/62 6-0:

More information

Union-find with deletions

Union-find with deletions 19 Union-find with deletions Haim Kaplan * Nira Shafrir Robert E. Tarjan ~ Abstract In the classical union-find problem we maintain a partition of a universe of n elements into disjoint sets subject to

More information

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes. 1. The advantage of.. is that they solve the problem if sequential storage representation. But disadvantage in that is they are sequential lists. [A] Lists [B] Linked Lists [A] Trees [A] Queues 2. The

More information

P. Jeyanthi and N. Angel Benseera

P. Jeyanthi and N. Angel Benseera Opuscula Math. 34, no. 1 (014), 115 1 http://dx.doi.org/10.7494/opmath.014.34.1.115 Opuscula Mathematica A TOTALLY MAGIC CORDIAL LABELING OF ONE-POINT UNION OF n COPIES OF A GRAPH P. Jeyanthi and N. Angel

More information

File Management. Chapter 12

File Management. Chapter 12 Chapter 12 File Management File is the basic element of most of the applications, since the input to an application, as well as its output, is usually a file. They also typically outlive the execution

More information

Strategic Deployment in Graphs. 1 Introduction. v 1 = v s. v 2. v 4. e 1. e 5 25. e 3. e 2. e 4

Strategic Deployment in Graphs. 1 Introduction. v 1 = v s. v 2. v 4. e 1. e 5 25. e 3. e 2. e 4 Informatica 39 (25) 237 247 237 Strategic Deployment in Graphs Elmar Langetepe and Andreas Lenerz University of Bonn, Department of Computer Science I, Germany Bernd Brüggemann FKIE, Fraunhofer-Institute,

More information

CSE 326: Data Structures B-Trees and B+ Trees

CSE 326: Data Structures B-Trees and B+ Trees Announcements (4//08) CSE 26: Data Structures B-Trees and B+ Trees Brian Curless Spring 2008 Midterm on Friday Special office hour: 4:-5: Thursday in Jaech Gallery (6 th floor of CSE building) This is

More information

Steiner Tree Approximation via IRR. Randomized Rounding

Steiner Tree Approximation via IRR. Randomized Rounding Steiner Tree Approximation via Iterative Randomized Rounding Graduate Program in Logic, Algorithms and Computation μπλ Network Algorithms and Complexity June 18, 2013 Overview 1 Introduction Scope Related

More information

From Last Time: Remove (Delete) Operation

From Last Time: Remove (Delete) Operation CSE 32 Lecture : More on Search Trees Today s Topics: Lazy Operations Run Time Analysis of Binary Search Tree Operations Balanced Search Trees AVL Trees and Rotations Covered in Chapter of the text From

More information

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2) Sorting revisited How did we use a binary search tree to sort an array of elements? Tree Sort Algorithm Given: An array of elements to sort 1. Build a binary search tree out of the elements 2. Traverse

More information

A 2-factor in which each cycle has long length in claw-free graphs

A 2-factor in which each cycle has long length in claw-free graphs A -factor in which each cycle has long length in claw-free graphs Roman Čada Shuya Chiba Kiyoshi Yoshimoto 3 Department of Mathematics University of West Bohemia and Institute of Theoretical Computer Science

More information

Determine If An Equation Represents a Function

Determine If An Equation Represents a Function Question : What is a linear function? The term linear function consists of two parts: linear and function. To understand what these terms mean together, we must first understand what a function is. The

More information

Linear functions Increasing Linear Functions. Decreasing Linear Functions

Linear functions Increasing Linear Functions. Decreasing Linear Functions 3.5 Increasing, Decreasing, Max, and Min So far we have been describing graphs using quantitative information. That s just a fancy way to say that we ve been using numbers. Specifically, we have described

More information

Linear Programming. March 14, 2014

Linear Programming. March 14, 2014 Linear Programming March 1, 01 Parts of this introduction to linear programming were adapted from Chapter 9 of Introduction to Algorithms, Second Edition, by Cormen, Leiserson, Rivest and Stein [1]. 1

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

Approximation Algorithms

Approximation Algorithms Approximation Algorithms or: How I Learned to Stop Worrying and Deal with NP-Completeness Ong Jit Sheng, Jonathan (A0073924B) March, 2012 Overview Key Results (I) General techniques: Greedy algorithms

More information

Mathematical Induction. Lecture 10-11

Mathematical Induction. Lecture 10-11 Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

More information

Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh

Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh Graph Theory: Graph theory can be defined as the study of graphs; Graphs are mathematical structures used to model pair-wise relations between

More information

root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain

root node level: internal node edge leaf node CS@VT Data Structures & Algorithms 2000-2009 McQuain inary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from each

More information

Distributed Computing over Communication Networks: Maximal Independent Set

Distributed Computing over Communication Networks: Maximal Independent Set Distributed Computing over Communication Networks: Maximal Independent Set What is a MIS? MIS An independent set (IS) of an undirected graph is a subset U of nodes such that no two nodes in U are adjacent.

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 27 Approximation Algorithms Load Balancing Weighted Vertex Cover Reminder: Fill out SRTEs online Don t forget to click submit Sofya Raskhodnikova 12/6/2011 S. Raskhodnikova;

More information

8. Matchings and Factors

8. Matchings and Factors 8. Matchings and Factors Consider the formation of an executive council by the parliament committee. Each committee needs to designate one of its members as an official representative to sit on the council,

More information

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology First Name: Family Name: Student Number: Class/Tutorial: WOLLONGONG COLLEGE AUSTRALIA A College of the University of Wollongong Diploma in Information Technology Final Examination Spring Session 2008 WUCT121

More information