Finding two vertex connected components in linear time

Size: px
Start display at page:

Download "Finding two vertex connected components in linear time"

Transcription

1 TO 1 Finding two vertex connected components in linear time Guy Kortsarz

2 TO 2 ackward edges Please read the DFS algorithm (its in the lecture notes). The DFS gives a tree. The edges on the tree are called tree edges. The rest are called backward edges. ackward edges must go from a vertex to its ancestor. Indeed what if there is a side edge a b and say that we got to a before b, Since b is unvisited (it came after a) we should have recursed with b. ut we backtracked, which is a contradiction. e prove a claim: laim: Every graph G(V,E) has a tree T(V,E ) so that every edge in E E is a backward edge.

3 TO 3 n example of a DFS run k=1 D E F G k=13. K=12 Y X k=2 D k=3 k=4 H Z E k=5 X J K F k=6 Y G k=7 k 8 H k=9 J k=11 K k=10 Figure 1: n example of a DFS ran

4 TO 4 The order of traversal of edges First, then (ignored), then D, then D, (backward edge. be for short) D, (be),, E, E (be) E (be), E, (ignored) EF, FE (ignored), FG, GH HE (be), HF (be), HG (ignored) HJ, JK, KH (be) KJ (ignored). acktrack to H, HZ, ZH (ignored) backtrack to. X X (ignored) XY, Y (be) YX (ignored) backtrack to. Finish.

5 TO 5 nother example E D F Y w P x S Z Q R Figure 2: Run DFS. Say the order we go over edges

6 TO 6 The tree E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 3: DFS run

7 TO 7 Order of the edges, (ignored),, (be) (ignored) D, D (be), D (be) D (ignored) DF, FE E, F (be) acktrack to D. DP, PQ (ignored), QP (ignored) QR, RS, SR (ignored) SQ (be), backtrack to D. DX, XD (ignored) XY, YE, Y (ignored), Z, Z (ignored) ZY (be) acktrack to. Finish.

8 TO 8 Long paths e show using DFS that any graph has a path of length at least m/n. If m = n 2 /20 for example this gives n/20 length path. Very long To find such a path just take any DFS tree and take the height. e now upper bound the number of edges as a function of the height. ecause all edges are backward edges n h m. This only happens with leaves of level h that have all edges to their ancestors. This implies that h m/n

9 TO 9 Separating vertices These are vertices whose removal disconnects the graph. E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 4: The Run of DFS Separating vertices here: {D,X,Y,P,Q}.

10 TO 10 trivial and slow algorithm to find all separating vertices Note we assume from now on that the graph is connected as otherwise it makes no sense e can go over all vertices and for each vertex remove it and all its edges. This means that the linked lists change. If we are now at vertex v look at G v. Do a SF from any s G v. If one of the distances is infinite v is a separating vertex. ut this taken O(n(n+m)). Thus is not linear in n and m. Our next task is to give an algorithm that finds all separating vertices in O(m+n)

11 TO 11 n algorithm to find all separating vertices Definition: separating vertex in a connected graph is a vertex whose deletion together with its edges, makes the graph disconnected. It is quite convenient that a vertex has only up edges. Let T v be the subtree rooted at v. Let p(v) be the parent of v. Not having side edges means that a vertex v can go to or above his parent only by going down to a descendant and using an up edge that goes above his parent. This is illustrated in the next slide by a figure.

12 TO 12 separating vertex U, UX, XM M M M M X X U E Y UY YE E EY MX FZ FU E XU U UD UY YU YE UZ ZU ZF 1 U U E X D Y Z 2 U X M M U X X 3 Y 9 Z 11 M M X M D E F 12 U X 5 6 D X U Y U E Z U F F Z U Figure 5: X is not a separating vertex. ecause it does not separate his three children from their grandparent. M can go down to and then to the root (thus if X is taken out M can reach its grandparent of X by going to the root and going down to U. has a backward edge above X, and so does D. However U is a separating vertex because Z can not go down T z and jump above U

13 TO 13 Low number of a vertex How close to the root can a vertex get? hat is the minimum k(v) that a vertex u can reach using at most one back edge? It may be that back edges do not help and the lowest k value that u can get to is k(u). It may be that u has back edges. The back edge that goes highest is a candidate for the low number. lso lets think of vertices on descendants of v have backward edges. Trampolines as I call it. Go down to the best trampoline and jump once.

14 TO 14 The definition of L(u) L(u) is the the vertex with least k value that a vertex can reach without using its parent. There are 3 ways to get lower L(P). 1. k(u) (meaning stay put). It is always true that L(P) k(p) 2. If a vertex has backward edges go out of u we can choose the L(u) to be the minimum k value. 3. U can go down to some T Q with Q a child of P and use one backward edge inside T Q. The least number it can get bounds L(P) from above

15 TO 15 Example U, UX, XM M M M M X X U E Y UY YE E EY MX FZ FU E XU U UD UY YU YE UZ ZU ZF 1 U U E X D Y Z 2 U X M M U X X 3 Y 9 Z 11 M M X M D E F 12 U X 5 6 D X U Y U E Z U F F Z U Figure 6: L() = 1 by rule 1. L(U) = 1 by going down to and jumping (rule 3). L(X) = 1 by rule 3. L(Y) = 1 by rule 3. L(Z) = 2 by rule 3. L(M) = 1 by rule 3. L() = 2 by rule 2. L(D) = 2 by rule 2. L(E) = 1 by rule 2. L(F) = 2 by rule 2. L() = 1 by rule 2. L() = 3 by rule 2.

16 TO 16 theorem vertex u is a separator vertex if and only if for every child v, low(v) < k(v). Namely if every child can reach the grandparent. Note that the grand parent can reach the root even if par(u) is remove and so can all other vertices. For example a vertex in T v a tree rooted by a child v of u has a path to par(par(u)) and so to the root, if par(u) is deleted.

17 TO 17 The inequality that implies a separating vertex Let v be the child of u with u not the root. If L(v) k(u) it means that v can not jump over his parent u. Thus the removal of u disconnects v from par(u). laim: a vertex u is separating if and only if for some child v of u, L(v) k(u). If this holds than after u is remove v and p(u) have no path in G u.

18 TO 18 The root will always be considered a separating vertex However the root is a separating vertex, if and only if it has at least two children. This is because up edges do not exist. If it has one child, clearly the removal of the root leaves a single connected component. If it has two children or more then as there are no side edges, the two children will become disconnected. For the purpose of finding 2 vertex connected components (later) its good to treat the root as a separating vertex

19 TO 19 Thinking on it as a recursive algorithm Let U ve a vertex and V 1,V 2,...,V k children of U. learly L(U) min{l(v 1 ),L(V 2 ),...,L(V k )} if z is a child of u then L(u) L(z). Think recursively. hen we get back to a child of Z, of U we know the low number of the child L(Z). Then we can set L(U) min{l(u),l(z)}. Second, when we discover a backward edge say UZ, then L(U) min{l(u),k(z)}. Read the algorithm for finding separating vertices (in the slide notes).

20 TO 20 Finding separating vertices E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 7: Finding separating vertices

21 TO 21 The run of the algorithm L() 1, L() 2, L() 3, L() 1, L(D) 4 L(D) 1 L(F) 5. L(E) 6, L(E) 4 L() 7 L() 5, acktrack L() < k(e). L(E) < k(f) L(F) k(d). D separator. L(P) 8, L(Q) 9, L(R) 10, L(S) 11. L(S) 9 acktrack L(R) 9. L(S) < k(r). acktrack. L(R) k(p), P is separating. L(P) > k(d),d is separator. L(X) 12. L(Y) 13, L() 14, L(Z) 15, L(Z) 13. L() 15 L(Z) < k(y). acktrack. L() 13. L() k(y), Y is separating. L(Y) k(x), X is sep. L(D) < k(), L() < k(). not separating.

22 TO 22 2 vertex connected components graph is vertex two connected if for every two vertices v,u in the graph there are at least two paths between u and v. nother way to say that a graph is two vertex connected is saying that graph has no separating vertices. If a graph is not two vertex connected a 2 connected component is a maximum size subgraph that is two vertex connected. 2 vertex connected component is also called a (bio connected component) if 1. The subgraph is two vertex connected and 2. The subgraph is not contained in a larger

23 TO 23 Examples In trees the are every edge (note that a vertex alone is never a ). Figure 8: The of a graph, example

24 TO 24 The theory of the laim: The size of the intersection over vertices of two is at most one. Namely the following is not possible. Figure 9: Two can not have intersection of size 2

25 TO 25 proof e show that if we remove, is still connected. similar proof holds for and an easier proof follows for removing any vertex that is not or. onsider alone, disregarding. This is a and in partial it it two vertex connected. Thus removing leaves a connecting graph. In the same way disregarding, removing from leaves a connected graph. Let 1 =, 2 =. e know that 1. 1 and 2 are connected. 2. They share a vertex and so 1 2 is connected. 3. ut this means that is a that contains both and. 4. This is a contradiction

26 TO 26 The unique intersecting vertex onsider the graph induced by. say that they intersect at a. See the following figure Figure 10: Two that intersect on a

27 TO 27 Proof oth X, X for X a can reach a as, are. If we remove a by the assumption toward a contradiction the graph remain connected. Thus is a two vertex connected subgraph, which is a contradiction

28 TO 28 a cycle of cant exist e define a path 1, 2, 3... on. The path is legal in i, i+1 intersect on separating vertex. Here is an example of a path of Figure 11: n example

29 TO 29 cycle can not exists G F E D Figure 12: This structure cant exist

30 TO 30 hy not? onsider the following example J 3 7 H F D Figure 13: This cant be

31 TO 31 Proof Say that is removed, separating 1 and 2. However by the definition of a, every vertex in 1 can reach J, then H, then F, then D then, Then which means that 1 can reach any vertex of 2. Thus the entire cycle in vertex 2-connected, contradiction.

32 TO 32 leaf component Let P be a longest path in a graphs. Let, be the two at the start and end of the path. The, can not intersect a that is outside as this will imply that the path is not longest. The can not intersect anyone in the middle of the path as otherwise we get a cycle of. Thus both, intersect one. y the claims above it contains one separating vertex. alled a leaf component. Theorem: There are always at least 2 with a single separating vertices. Remark: Most have much more than be separating vertex.

33 TO 33 high level of a run 6 E E 5 D D Figure 14: Moving via non leaf until we get to a leaf

34 TO 34 Intuition for finding onsider an edge eating monster. He eats an edge and also pushes it to a STK. It starts at some 1. Unfortunately, it may leave 1 to 2 2 before it eats (puts on the stack) all the edges of 1. Now, since 1 has more than one separating vertex the monster can get out of 1 before it eats all the edges of 1. It goes out by another separating vertex. The same hold true for 2, 3, 4, 5.

35 TO 35 ontinued hat we have on the stack is a completely mixed collection of edges. How do we find a? ut it must eventually reach a leaf components, 6. 6 has one separating vertex. Think of separating vertices as out points. If you have one end point, (one separating vertex) you will eat all the edges before you backtrack. t this moment all the edges of all the leaf are on the top of the stack. The deep most edge in the Stack (hence the one to go out first is U V that enters the and means that U is a separating vertex. e will discover at that stage that L(F) k(e) thus we found a separating vertex. nd since we backtracked, Finding a separating vertex implies we also found a leaf component.

36 TO 36 hat do we know Say that E separates F. So EF was the first edge (and also first edge in the stack) among the edges of 6. e know that we backtrack, so the 6 must be a leaf (if there are two separating vertices we will leave the when we get to the second separating vertex). It may not have been a leaf at start but its a leaf now. This does not mix edges of 6 with the edges of any because we backtracked.

37 TO 37 ontinued It very simple to find the. Each time you find a separating vertex it means that you did backtracking, and so the of this vertex is a leaf component. If you enter the component with XY XY will be the first in the stack. edge in the because we used a stack. s soon as we find the X is a separating vertex for Y, remove all the edges until XY including. Declare that the next. e now go over the algorithm and later see an example. Think why it is good that the root is always considered a separating vertex

38 TO 38 n example of a run of the algorithm E k=1 D F Y w k=2 k=3 P x S Z X k=12 k=8 P D k=4 k=5 F Q R Y k=14 k=13 R Q k=10 k=9 E k=6 k=7 Z k=15 S k=11 Figure 15: The Run of DFS

39 TO 39 The run {(,),(,),(,),(,D),(D,),(D,), (D,F),(F,E),(E,D),(E,),(,F)} acktrack, D separating F, Take all edges till (D,F) {(D,F),(F,E),(E,D))(E,),(,F)} First. {(),(,),(,),(,D),(D,),(D,), (D,P)(P,Q),(Q,R),(R,S)),(S,Q)}. Q separate R. ll edges till (Q,R). {(Q,R),(R,S),(S,Q)} are the next.

40 TO 40 ontinued {(),(,),(,),(,D),(D,),(D,), (D,X),(X,Y)(Y,),(.Z),(Z,Y)}. Y separates. Next {(Y,),(,Z),(Z,Y)} {(,),(,),(,),(,D),(D,), (D,X)(X,Y)} X separates Y, thus {(X.Y)} the next. D separates X and so {(D,X)}, next. ack to, {(),(,),(,),(,D),(D,),(D,)}. ll the edges, last. ecause considered a separating vertex.

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim: We have seen that the insert operation on a RB takes an amount of time proportional to the number of the levels of the tree (since the additional operations required to do any rebalancing require constant

More information

Graph Algorithms Using Depth First Search

Graph Algorithms Using Depth First Search Graph Algorithms Using Depth First Search Analysis of Algorithms Week 8, Lecture 1 Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Graph Algorithms Using Depth

More information

MAL 376: Graph Algorithms I Semester Lecture 1: July 24

MAL 376: Graph Algorithms I Semester Lecture 1: July 24 MAL 376: Graph Algorithms I Semester 2014-2015 Lecture 1: July 24 Course Coordinator: Prof. B. S. Panda Scribes: Raghuvansh, Himanshu, Mohit, Abhishek Disclaimer: These notes have not been subjected to

More information

Lecture 3: Graphs and flows

Lecture 3: Graphs and flows Chapter 3 Lecture 3: Graphs and flows Graphs: a useful combinatorial structure. Definitions: graph, directed and undirected graph, edge as ordered pair, path, cycle, connected graph, strongly connected

More information

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests 4 Basics of Trees Trees, actually acyclic connected simple graphs, are among the simplest graph classes. Despite their simplicity, they still have rich structure and many useful application, such as in

More information

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees trees CS 220: Discrete Structures and their Applications A tree is an undirected graph that is connected and has no cycles. Trees Chapter 11 in zybooks rooted trees Rooted trees. Given a tree T, choose

More information

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017 12. Graphs and Trees 2 Aaron Tan 6 10 November 2017 1 10.5 Trees 2 Definition Definition Definition: Tree A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree

More information

Treewidth and graph minors

Treewidth and graph minors Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under

More information

Graph Algorithms. Definition

Graph 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 information

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College

Graphs. Part I: Basic algorithms. Laura Toma Algorithms (csci2200), Bowdoin College Laura Toma Algorithms (csci2200), Bowdoin College Undirected graphs Concepts: connectivity, connected components paths (undirected) cycles Basic problems, given undirected graph G: is G connected how many

More information

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph. Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial

More information

Cut vertices, Cut Edges and Biconnected components. MTL776 Graph algorithms

Cut vertices, Cut Edges and Biconnected components. MTL776 Graph algorithms Cut vertices, Cut Edges and Biconnected components MTL776 Graph algorithms Articulation points, Bridges, Biconnected Components Let G = (V;E) be a connected, undirected graph. An articulation point of

More information

MATH 409 LECTURE 10 DIJKSTRA S ALGORITHM FOR SHORTEST PATHS

MATH 409 LECTURE 10 DIJKSTRA S ALGORITHM FOR SHORTEST PATHS MATH 409 LECTURE 10 DIJKSTRA S ALGORITHM FOR SHORTEST PATHS REKHA THOMAS In this lecture we see the first algorithm to compute shortest paths from a given vertex r to all vertices v in a digraph G without

More information

In this lecture, we ll look at applications of duality to three problems:

In this lecture, we ll look at applications of duality to three problems: Lecture 7 Duality Applications (Part II) In this lecture, we ll look at applications of duality to three problems: 1. Finding maximum spanning trees (MST). We know that Kruskal s algorithm finds this,

More information

22.3 Depth First Search

22.3 Depth First Search 22.3 Depth First Search Depth-First Search(DFS) always visits a neighbour of the most recently visited vertex with an unvisited neighbour. This means the search moves forward when possible, and only backtracks

More information

Parameterized coloring problems on chordal graphs

Parameterized coloring problems on chordal graphs Parameterized coloring problems on chordal graphs Dániel Marx Department of Computer Science and Information Theory, Budapest University of Technology and Economics Budapest, H-1521, Hungary dmarx@cs.bme.hu

More information

Problem Set 2 Solutions

Problem Set 2 Solutions Problem Set 2 Solutions Graph Theory 2016 EPFL Frank de Zeeuw & Claudiu Valculescu 1. Prove that the following statements about a graph G are equivalent. - G is a tree; - G is minimally connected (it is

More information

Module 5 Graph Algorithms

Module 5 Graph Algorithms Module 5 Graph lgorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu 5. Graph Traversal lgorithms Depth First

More information

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other.

Strongly connected: A directed graph is strongly connected if every pair of vertices are reachable from each other. Directed Graph In a directed graph, each edge (u, v) has a direction u v. Thus (u, v) (v, u). Directed graph is useful to model many practical problems (such as one-way road in traffic network, and asymmetric

More information

HW Graph Theory SOLUTIONS (hbovik) - Q

HW Graph Theory SOLUTIONS (hbovik) - Q 1, Diestel 9.3: An arithmetic progression is an increasing sequence of numbers of the form a, a+d, a+ d, a + 3d.... Van der Waerden s theorem says that no matter how we partition the natural numbers into

More information

CMSC th Lecture: Graph Theory: Trees.

CMSC th Lecture: Graph Theory: Trees. CMSC 27100 26th Lecture: Graph Theory: Trees. Lecturer: Janos Simon December 2, 2018 1 Trees Definition 1. A tree is an acyclic connected graph. Trees have many nice properties. Theorem 2. The following

More information

Discrete mathematics

Discrete mathematics Discrete mathematics Petr Kovář petr.kovar@vsb.cz VŠB Technical University of Ostrava DiM 470-2301/02, Winter term 2018/2019 About this file This file is meant to be a guideline for the lecturer. Many

More information

Introduction to Computers and Programming. Concept Question

Introduction to Computers and Programming. Concept Question Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 7 April 2 2004 Concept Question G1(V1,E1) A graph G(V, where E) is V1 a finite = {}, nonempty E1 = {} set of G2(V2,E2) vertices and

More information

Lecture 20 : Trees DRAFT

Lecture 20 : Trees DRAFT CS/Math 240: Introduction to Discrete Mathematics 4/12/2011 Lecture 20 : Trees Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last time we discussed graphs. Today we continue this discussion,

More information

(Refer Slide Time: 02.06)

(Refer Slide Time: 02.06) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 27 Depth First Search (DFS) Today we are going to be talking

More information

K 4 C 5. Figure 4.5: Some well known family of graphs

K 4 C 5. Figure 4.5: Some well known family of graphs 08 CHAPTER. TOPICS IN CLASSICAL GRAPH THEORY K, K K K, K K, K K, K C C C C 6 6 P P P P P. Graph Operations Figure.: Some well known family of graphs A graph Y = (V,E ) is said to be a subgraph of a graph

More information

Chapter 11: Graphs and Trees. March 23, 2008

Chapter 11: Graphs and Trees. March 23, 2008 Chapter 11: Graphs and Trees March 23, 2008 Outline 1 11.1 Graphs: An Introduction 2 11.2 Paths and Circuits 3 11.3 Matrix Representations of Graphs 4 11.5 Trees Graphs: Basic Definitions Informally, a

More information

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1

Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 CME 305: Discrete Mathematics and Algorithms Instructor: Professor Aaron Sidford (sidford@stanford.edu) January 11, 2018 Lecture 2 - Graph Theory Fundamentals - Reachability and Exploration 1 In this lecture

More information

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology Trees : Part Section. () (2) Preorder, Postorder and Levelorder Traversals Definition: A tree is a connected graph with no cycles Consequences: Between any two vertices, there is exactly one unique path

More information

Binary Heaps in Dynamic Arrays

Binary 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 information

Finding k-paths in Cycle Free Graphs

Finding k-paths in Cycle Free Graphs Finding k-paths in Cycle Free Graphs Aviv Reznik Under the Supervision of Professor Oded Goldreich Department of Computer Science and Applied Mathematics Weizmann Institute of Science Submitted for the

More information

(Refer Slide Time: 06:01)

(Refer Slide Time: 06:01) Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 28 Applications of DFS Today we are going to be talking about

More information

COL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:

COL351: 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 information

Searching in Graphs (cut points)

Searching in Graphs (cut points) 0 November, 0 Breath First Search (BFS) in Graphs In BFS algorithm we visit the verices level by level. The BFS algorithm creates a tree with root s. Once a node v is discovered by BFS algorithm we put

More information

March 20/2003 Jayakanth Srinivasan,

March 20/2003 Jayakanth Srinivasan, Definition : A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges. Definition : In a multigraph G = (V, E) two or

More information

Flow Graph Theory. Depth-First Ordering Efficiency of Iterative Algorithms Reducible Flow Graphs

Flow Graph Theory. Depth-First Ordering Efficiency of Iterative Algorithms Reducible Flow Graphs Flow Graph Theory Depth-First Ordering Efficiency of Iterative Algorithms Reducible Flow Graphs 1 Roadmap Proper ordering of nodes of a flow graph speeds up the iterative algorithms: depth-first ordering.

More information

ifn >-- 2 is even, ifn is odd, ifn =0,

ifn >-- 2 is even, ifn is odd, ifn =0, SIAM J. ALG. DISC. METH. Voi. 7, No. 1, January 1986 1986 Society for Industrial and Applied Mathematics 015 THE NUMBER OF MAXIMAL INDEPENDENT SETS IN A TREE* HERBERT S. WILFf Abstract. can have. We find

More information

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES HPTER 5 RELTIONSHIPS WITHIN TRINGLES In this chapter we address three ig IES: 1) Using properties of special segments in triangles 2) Using triangle inequalities to determine what triangles are possible

More information

6. Finding Efficient Compressions; Huffman and Hu-Tucker

6. Finding Efficient Compressions; Huffman and Hu-Tucker 6. Finding Efficient Compressions; Huffman and Hu-Tucker We now address the question: how do we find a code that uses the frequency information about k length patterns efficiently to shorten our message?

More information

Graph Algorithms. Imran Rashid. Jan 16, University of Washington

Graph Algorithms. Imran Rashid. Jan 16, University of Washington Graph Algorithms Imran Rashid University of Washington Jan 16, 2008 1 / 26 Lecture Outline 1 BFS Bipartite Graphs 2 DAGs & Topological Ordering 3 DFS 2 / 26 Lecture Outline 1 BFS Bipartite Graphs 2 DAGs

More information

15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017

15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017 15-451/651: Design & Analysis of Algorithms October 5, 2017 Lecture #11: Depth First Search and Strong Components last changed: October 17, 2017 1 Introduction Depth first search is a very useful technique

More information

Lecture 14: March 9, 2015

Lecture 14: March 9, 2015 324: tate-space, F, F, Uninformed earch. pring 2015 Lecture 14: March 9, 2015 Lecturer: K.R. howdhary : Professor of (VF) isclaimer: These notes have not been subjected to the usual scrutiny reserved for

More information

CS24 Week 8 Lecture 1

CS24 Week 8 Lecture 1 CS24 Week 8 Lecture 1 Kyle Dewey Overview Tree terminology Tree traversals Implementation (if time) Terminology Node The most basic component of a tree - the squares Edge The connections between nodes

More information

{ 1} Definitions. 10. Extremal graph theory. Problem definition Paths and cycles Complete subgraphs

{ 1} Definitions. 10. Extremal graph theory. Problem definition Paths and cycles Complete subgraphs Problem definition Paths and cycles Complete subgraphs 10. Extremal graph theory 10.1. Definitions Let us examine the following forbidden subgraph problems: At most how many edges are in a graph of order

More information

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.

Trees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures. Trees Q: Why study trees? : Many advance DTs are implemented using tree-based data structures. Recursive Definition of (Rooted) Tree: Let T be a set with n 0 elements. (i) If n = 0, T is an empty tree,

More information

Fully dynamic algorithm for recognition and modular decomposition of permutation graphs

Fully dynamic algorithm for recognition and modular decomposition of permutation graphs Fully dynamic algorithm for recognition and modular decomposition of permutation graphs Christophe Crespelle Christophe Paul CNRS - Département Informatique, LIRMM, Montpellier {crespell,paul}@lirmm.fr

More information

Recoloring k-degenerate graphs

Recoloring k-degenerate graphs Recoloring k-degenerate graphs Jozef Jirásek jirasekjozef@gmailcom Pavel Klavík pavel@klavikcz May 2, 2008 bstract This article presents several methods of transforming a given correct coloring of a k-degenerate

More information

Algorithmic Aspects of Communication Networks

Algorithmic Aspects of Communication Networks Algorithmic Aspects of Communication Networks Chapter 5 Network Resilience Algorithmic Aspects of ComNets (WS 16/17): 05 Network Resilience 1 Introduction and Motivation Network resilience denotes the

More information

Trees Algorhyme by Radia Perlman

Trees Algorhyme by Radia Perlman Algorhyme by Radia Perlman I think that I shall never see A graph more lovely than a tree. A tree whose crucial property Is loop-free connectivity. A tree which must be sure to span. So packets can reach

More information

On 2-Subcolourings of Chordal Graphs

On 2-Subcolourings of Chordal Graphs On 2-Subcolourings of Chordal Graphs Juraj Stacho School of Computing Science, Simon Fraser University 8888 University Drive, Burnaby, B.C., Canada V5A 1S6 jstacho@cs.sfu.ca Abstract. A 2-subcolouring

More information

st-orientations September 29, 2005

st-orientations September 29, 2005 st-orientations September 29, 2005 Introduction Let G = (V, E) be an undirected biconnected graph of n nodes and m edges. The main problem this chapter deals with is different algorithms for orienting

More information

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND

CSE 373 MAY 10 TH SPANNING TREES AND UNION FIND CSE 373 MAY 0 TH SPANNING TREES AND UNION FIND COURSE LOGISTICS HW4 due tonight, if you want feedback by the weekend COURSE LOGISTICS HW4 due tonight, if you want feedback by the weekend HW5 out tomorrow

More information

Trees. Arash Rafiey. 20 October, 2015

Trees. Arash Rafiey. 20 October, 2015 20 October, 2015 Definition Let G = (V, E) be a loop-free undirected graph. G is called a tree if G is connected and contains no cycle. Definition Let G = (V, E) be a loop-free undirected graph. G is called

More information

Outline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black.

Outline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black. Outline 1 Definition Computer Science 331 Red-Black rees Mike Jacobson Department of Computer Science University of Calgary Lectures #20-22 2 Height-Balance 3 Searches 4 Rotations 5 s: Main Case 6 Partial

More information

LECTURE 11 TREE TRAVERSALS

LECTURE 11 TREE TRAVERSALS DATA STRUCTURES AND ALGORITHMS LECTURE 11 TREE TRAVERSALS IMRAN IHSAN ASSISTANT PROFESSOR AIR UNIVERSITY, ISLAMABAD BACKGROUND All the objects stored in an array or linked list can be accessed sequentially

More information

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES

CHAPTER 5 RELATIONSHIPS WITHIN TRIANGLES HPTR 5 RLTIONSHIPS WITHIN TRINGLS In this chapter we address three ig IS: 1) Using properties of special segments in triangles ) Using triangle inequalities to determine what triangles are possible 3)

More information

Chapter 15. Binary Search Trees (BSTs) Preliminaries

Chapter 15. Binary Search Trees (BSTs) Preliminaries Chapter 15 Binary Search Trees (BSTs) Search trees are data structures that can be used to efficiently support searches and updates on collections of items that satisfy a total order. Probably, the most

More information

We assume uniform hashing (UH):

We assume uniform hashing (UH): We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a

More information

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION CHAPTER 5 SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION Alessandro Artale UniBZ - http://www.inf.unibz.it/ artale/ SECTION 5.5 Application: Correctness of Algorithms Copyright Cengage Learning. All

More information

DOUBLE DOMINATION CRITICAL AND STABLE GRAPHS UPON VERTEX REMOVAL 1

DOUBLE DOMINATION CRITICAL AND STABLE GRAPHS UPON VERTEX REMOVAL 1 Discussiones Mathematicae Graph Theory 32 (2012) 643 657 doi:10.7151/dmgt.1633 DOUBLE DOMINATION CRITICAL AND STABLE GRAPHS UPON VERTEX REMOVAL 1 Soufiane Khelifi Laboratory LMP2M, Bloc of laboratories

More information

Depth-First Search Depth-first search (DFS) is another way to traverse the graph.

Depth-First Search Depth-first search (DFS) is another way to traverse the graph. Depth-First Search Depth-first search (DFS) is another way to traverse the graph. Motivating example: In a video game, you are searching for a path from a point in a maze to the exit. The maze can be modeled

More information

MATH20902: Discrete Maths, Solutions to Problem Set 1. These solutions, as well as the corresponding problems, are available at

MATH20902: Discrete Maths, Solutions to Problem Set 1. These solutions, as well as the corresponding problems, are available at MATH20902: Discrete Maths, Solutions to Problem Set 1 These solutions, as well as the corresponding problems, are available at https://bit.ly/mancmathsdiscrete.. (1). The upper panel in the figure below

More information

Search Trees. Undirected graph Directed graph Tree Binary search tree

Search Trees. Undirected graph Directed graph Tree Binary search tree Search Trees Undirected graph Directed graph Tree Binary search tree 1 Binary Search Tree Binary search key property: Let x be a node in a binary search tree. If y is a node in the left subtree of x, then

More information

Randomized incremental construction. Trapezoidal decomposition: Special sampling idea: Sample all except one item

Randomized incremental construction. Trapezoidal decomposition: Special sampling idea: Sample all except one item Randomized incremental construction Special sampling idea: Sample all except one item hope final addition makes small or no change Method: process items in order average case analysis randomize order to

More information

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010

Uses for Trees About Trees Binary Trees. Trees. Seth Long. January 31, 2010 Uses for About Binary January 31, 2010 Uses for About Binary Uses for Uses for About Basic Idea Implementing Binary Example: Expression Binary Search Uses for Uses for About Binary Uses for Storage Binary

More information

1 Variations of the Traveling Salesman Problem

1 Variations of the Traveling Salesman Problem Stanford University CS26: Optimization Handout 3 Luca Trevisan January, 20 Lecture 3 In which we prove the equivalence of three versions of the Traveling Salesman Problem, we provide a 2-approximate algorithm,

More information

CS 310 Advanced Data Structures and Algorithms

CS 310 Advanced Data Structures and Algorithms CS 31 Advanced Data Structures and Algorithms Graphs July 18, 17 Tong Wang UMass Boston CS 31 July 18, 17 1 / 4 Graph Definitions Graph a mathematical construction that describes objects and relations

More information

1 Maximum Independent Set

1 Maximum Independent Set CS 408 Embeddings and MIS Abhiram Ranade In this lecture we will see another application of graph embedding. We will see that certain problems (e.g. maximum independent set, MIS) can be solved fast for

More information

An O(m + nlog n) On-Line Algorithm for Recognizing Interval Graphs

An O(m + nlog n) On-Line Algorithm for Recognizing Interval Graphs An O(m + nlog n) On-Line Algorithm for Recognizing Interval Graphs Wen-Lian Hsu Institute of Information Science, Academia Sinica, Taipei, Taiwan, R.O.C. Abstract. Since the invention of PQ-trees by Booth

More information

1 Leaffix Scan, Rootfix Scan, Tree Size, and Depth

1 Leaffix Scan, Rootfix Scan, Tree Size, and Depth Lecture 17 Graph Contraction I: Tree Contraction Parallel and Sequential Data Structures and Algorithms, 15-210 (Spring 2012) Lectured by Kanat Tangwongsan March 20, 2012 In this lecture, we will explore

More information

Binary Search Trees. Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250

Binary Search Trees. Carlos Moreno uwaterloo.ca EIT https://ece.uwaterloo.ca/~cmoreno/ece250 Carlos Moreno cmoreno @ uwaterloo.ca EIT-4103 https://ece.uwaterloo.ca/~cmoreno/ece250 Standard reminder to set phones to silent/vibrate mode, please! Previously, on ECE-250... We discussed trees (the

More information

Matching Theory. Figure 1: Is this graph bipartite?

Matching Theory. Figure 1: Is this graph bipartite? Matching Theory 1 Introduction A matching M of a graph is a subset of E such that no two edges in M share a vertex; edges which have this property are called independent edges. A matching M is said to

More information

Notes on Binary Dumbbell Trees

Notes on Binary Dumbbell Trees Notes on Binary Dumbbell Trees Michiel Smid March 23, 2012 Abstract Dumbbell trees were introduced in [1]. A detailed description of non-binary dumbbell trees appears in Chapter 11 of [3]. These notes

More information

Binary Trees

Binary Trees Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what

More information

Scribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017

Scribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017 CS6 Lecture 4 Greedy Algorithms Scribe: Virginia Williams, Sam Kim (26), Mary Wootters (27) Date: May 22, 27 Greedy Algorithms Suppose we want to solve a problem, and we re able to come up with some recursive

More information

Trapezoidal decomposition:

Trapezoidal decomposition: Trapezoidal decomposition: Motivation: manipulate/analayze a collection of segments e.g. detect segment intersections e.g., point location data structure Definition. Draw verticals at all points binary

More information

An eccentric coloring of trees

An eccentric coloring of trees AUSTRALASIAN JOURNAL OF COMBINATORICS Volume 9 (004), Pages 309 3 An eccentric coloring of trees Christian Sloper Department of Informatics University of Bergen Norway sloper@ii.uib.no Abstract Eccentric

More information

13.4 Deletion in red-black trees

13.4 Deletion in red-black trees Deletion in a red-black tree is similar to insertion. Apply the deletion algorithm for binary search trees. Apply node color changes and left/right rotations to fix the violations of RBT tree properties.

More information

Lecture 10: Strongly Connected Components, Biconnected Graphs

Lecture 10: Strongly Connected Components, Biconnected Graphs 15-750: Graduate Algorithms February 8, 2016 Lecture 10: Strongly Connected Components, Biconnected Graphs Lecturer: David Witmer Scribe: Zhong Zhou 1 DFS Continued We have introduced Depth-First Search

More information

Section 3.1: Nonseparable Graphs Cut vertex of a connected graph G: A vertex x G such that G x is not connected. Theorem 3.1, p. 57: Every connected

Section 3.1: Nonseparable Graphs Cut vertex of a connected graph G: A vertex x G such that G x is not connected. Theorem 3.1, p. 57: Every connected Section 3.1: Nonseparable Graphs Cut vertex of a connected graph G: A vertex x G such that G x is not connected. Theorem 3.1, p. 57: Every connected graph G with at least 2 vertices contains at least 2

More information

Non-context-Free Languages. CS215, Lecture 5 c

Non-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 information

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302

Topics. Trees Vojislav Kecman. Which graphs are trees? Terminology. Terminology Trees as Models Some Tree Theorems Applications of Trees CMSC 302 Topics VCU, Department of Computer Science CMSC 302 Trees Vojislav Kecman Terminology Trees as Models Some Tree Theorems Applications of Trees Binary Search Tree Decision Tree Tree Traversal Spanning Trees

More information

6. Finding Efficient Compressions; Huffman and Hu-Tucker Algorithms

6. Finding Efficient Compressions; Huffman and Hu-Tucker Algorithms 6. Finding Efficient Compressions; Huffman and Hu-Tucker Algorithms We now address the question: How do we find a code that uses the frequency information about k length patterns efficiently, to shorten

More information

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review

CS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review 1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,

More information

Exact Top-k Nearest Keyword Search in Large Networks

Exact Top-k Nearest Keyword Search in Large Networks Exact Top-k Nearest Keyword Search in Large Networks Minhao Jiang, Ada Wai-Chee Fu, Raymond Chi-Wing Wong The Hong Kong University of Science and Technology The Chinese University of Hong Kong {mjiangac,

More information

13.4 Deletion in red-black trees

13.4 Deletion in red-black trees The operation of Deletion in a red-black tree is similar to the operation of Insertion on the tree. That is, apply the deletion algorithm for binary search trees to delete a node z; apply node color changes

More information

arxiv: v1 [cs.cg] 15 Jan 2015

arxiv: v1 [cs.cg] 15 Jan 2015 Packing Plane Perfect Matchings into a Point Set Ahmad Biniaz Prosenjit Bose Anil Maheshwari Michiel Smid January 16, 015 arxiv:1501.03686v1 [cs.cg] 15 Jan 015 Abstract Given a set P of n points in the

More information

Dominance Constraints and Dominance Graphs

Dominance Constraints and Dominance Graphs Dominance Constraints and Dominance Graphs David Steurer Saarland University Abstract. Dominance constraints logically describe trees in terms of their adjacency and dominance, i.e. reachability, relation.

More information

6.854J / J Advanced Algorithms Fall 2008

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

More information

Definition of Graphs and Trees. Representation of Trees.

Definition of Graphs and Trees. Representation of Trees. Definition of Graphs and Trees. Representation of Trees. Chapter 6 Definition of graphs (I) A directed graph or digraph is a pair G = (V,E) s.t.: V is a finite set called the set of vertices of G. E V

More information

Classic Graph Theory Problems

Classic Graph Theory Problems Classic Graph Theory Problems Hiroki Sayama sayama@binghamton.edu The Origin Königsberg bridge problem Pregel River (Solved negatively by Euler in 176) Representation in a graph Can all the seven edges

More information

CE 221 Data Structures and Algorithms

CE 221 Data Structures and Algorithms CE 221 Data Structures and Algorithms Chapter 4: Trees (Binary) Text: Read Weiss, 4.1 4.2 Izmir University of Economics 1 Preliminaries - I (Recursive) Definition: A tree is a collection of nodes. The

More information

Math 777 Graph Theory, Spring, 2006 Lecture Note 1 Planar graphs Week 1 Weak 2

Math 777 Graph Theory, Spring, 2006 Lecture Note 1 Planar graphs Week 1 Weak 2 Math 777 Graph Theory, Spring, 006 Lecture Note 1 Planar graphs Week 1 Weak 1 Planar graphs Lectured by Lincoln Lu Definition 1 A drawing of a graph G is a function f defined on V (G) E(G) that assigns

More information

Applications of BDF and DFS

Applications of BDF and DFS January 14, 2016 1 Deciding whether a graph is bipartite using BFS. 2 Finding connected components of a graph (both BFS and DFS) works. 3 Deciding whether a digraph is strongly connected. 4 Finding cut

More information

Minimum spanning trees

Minimum spanning trees Carlos Moreno cmoreno @ uwaterloo.ca EI-3 https://ece.uwaterloo.ca/~cmoreno/ece5 Standard reminder to set phones to silent/vibrate mode, please! During today's lesson: Introduce the notion of spanning

More information

Broadcast: Befo re 1

Broadcast: Befo re 1 Broadcast: Before 1 After 2 Spanning Tree ffl assume fixed spanning tree ffl asynchronous model 3 Processor State parent terminated children 4 Broadcast: Step One parent terminated children 5 Broadcast:Step

More information

Rainbow game domination subdivision number of a graph

Rainbow game domination subdivision number of a graph Rainbow game domination subdivision number of a graph J. Amjadi Department of Mathematics Azarbaijan Shahid Madani University Tabriz, I.R. Iran j-amjadi@azaruniv.edu Abstract The rainbow game domination

More information

The priority is indicated by a number, the lower the number - the higher the priority.

The priority is indicated by a number, the lower the number - the higher the priority. CmSc 250 Intro to Algorithms Priority Queues 1. Introduction Usage of queues: in resource management: several users waiting for one and the same resource. Priority queues: some users have priority over

More information

COMP 251 Winter 2017 Online quizzes with answers

COMP 251 Winter 2017 Online quizzes with answers COMP 251 Winter 2017 Online quizzes with answers Open Addressing (2) Which of the following assertions are true about open address tables? A. You cannot store more records than the total number of slots

More information

CSE 530A. B+ Trees. Washington University Fall 2013

CSE 530A. B+ Trees. Washington University Fall 2013 CSE 530A B+ Trees Washington University Fall 2013 B Trees A B tree is an ordered (non-binary) tree where the internal nodes can have a varying number of child nodes (within some range) B Trees When a key

More information