CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Similar documents
Lecture 22 Tuesday, April 10

Copyright 2000, Kevin Wayne 1

Name: Lirong TAN 1. (15 pts) (a) Define what is a shortest s-t path in a weighted, connected graph G.

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

Copyright 2000, Kevin Wayne 1

CSE 20 DISCRETE MATH WINTER

CS70: Discrete Math and Probability. Fan Ye June 23, 2016

Reductions and Satisfiability

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Greedy algorithms is another useful way for solving optimization problems.

Graph Definitions. In a directed graph the edges have directions (ordered pairs). A weighted graph includes a weight function.

2. CONNECTIVITY Connectivity

HW Graph Theory SOLUTIONS (hbovik) - Q

Theorem 2.9: nearest addition algorithm

Kruskal s MST Algorithm

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

Discrete Mathematics Lecture 4. Harper Langston New York University

CS 6783 (Applied Algorithms) Lecture 5

Ma/CS 6b Class 5: Graph Connectivity

CSC 373: Algorithm Design and Analysis Lecture 4

Greedy Algorithms. Previous Examples: Huffman coding, Minimum Spanning Tree Algorithms

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

CSE 20 DISCRETE MATH. Fall

CSE 331: Introduction to Algorithm Analysis and Design Graphs

Computer Science 236 Fall Nov. 11, 2010

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

Solutions to In-Class Problems Week 4, Fri

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

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

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

Modules. 6 Hamilton Graphs (4-8 lectures) Introduction Necessary conditions and sufficient conditions Exercises...

Outline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include

CSE331 Introduction to Algorithms Lecture 15 Minimum Spanning Trees

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Ma/CS 6b Class 26: Art Galleries and Politicians

GRAPH THEORY: AN INTRODUCTION

Solutions to In Class Problems Week 5, Wed.

CSC 373: Algorithm Design and Analysis Lecture 3

NP and computational intractability. Kleinberg and Tardos, chapter 8

8 Matroid Intersection

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Notes for Recitation 8

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

CSE 20 DISCRETE MATH. Winter

Solution to Graded Problem Set 4

Module 7. Independent sets, coverings. and matchings. Contents

Solutions to Quiz 1. (a) (3 points) Vertices x and y are in the same connected component. Solution. P (x, y)

II (Sorting and) Order Statistics

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Lecture 5: Graphs. Graphs! Euler Definitions: model. Fact! Euler Again!! Planar graphs. Euler Again!!!!

Recursion: The Beginning

Greedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d

Recursive Definitions Structural Induction Recursive Algorithms

P and NP (Millenium problem)

Assignment 1. Stefano Guerra. October 11, The following observation follows directly from the definition of in order and pre order traversal:

1. Chapter 1, # 1: Prove that for all sets A, B, C, the formula

Lecture 19 Thursday, March 29. Examples of isomorphic, and non-isomorphic graphs will be given in class.

A Reduction of Conway s Thrackle Conjecture

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

COT 3100 Spring 2010 Midterm 2

Theorem 3.1 (Berge) A matching M in G is maximum if and only if there is no M- augmenting path.

Propositional Logic Formal Syntax and Semantics. Computability and Logic

Matching Algorithms. Proof. If a bipartite graph has a perfect matching, then it is easy to see that the right hand side is a necessary condition.

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

On Covering a Graph Optimally with Induced Subgraphs

4.1 Interval Scheduling

Greedy Algorithms Part Three

1 Digraphs. Definition 1

2009 HMMT Team Round. Writing proofs. Misha Lavrov. ARML Practice 3/2/2014

CSE Winter 2015 Quiz 2 Solutions

Algorithm Design and Analysis

Lecture 6,

Approximation Algorithms

Definition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1

END-TERM EXAMINATION

DO NOT RE-DISTRIBUTE THIS SOLUTION FILE

Edge Colorings of Complete Multipartite Graphs Forbidding Rainbow Cycles

COMP3121/3821/9101/ s1 Assignment 1

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Lamé s Theorem. Strings. Recursively Defined Sets and Structures. Recursively Defined Sets and Structures

Propositional Logic. Andreas Klappenecker

Applied Algorithm Design Lecture 3

CS 3512, Spring Instructor: Doug Dunham. Textbook: James L. Hein, Discrete Structures, Logic, and Computability, 3rd Ed. Jones and Barlett, 2010

Definition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.

The strong chromatic number of a graph

DESIGN AND ANALYSIS OF ALGORITHMS

The Art Gallery Problem: An Overview and Extension to Chromatic Coloring and Mobile Guards

1 Undirected Vertex Geography UVG

Module 11. Directed Graphs. Contents

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:

NOTE ON MINIMALLY k-connected GRAPHS

Maximal Monochromatic Geodesics in an Antipodal Coloring of Hypercube

Test 1, Spring 2013 ( Solutions): Provided by Jeff Collins and Anil Patel. 1. Axioms for a finite AFFINE plane of order n.

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Graph Algorithms. Tours in Graphs. Graph Algorithms

Chapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms

Flexible Coloring. Xiaozhou Li a, Atri Rudra b, Ram Swaminathan a. Abstract

Transcription:

Recap. Growth rates: Arrange the following functions in ascending order of growth rate: n 2 log n n log n 2 log n n/ log n n n

Introduction Algorithm: A step-by-step way of solving a problem. Design of Algorithms: Algorithm is more of an art than science However, we will learn some basic tools and techniques that have evolved over time. These tools and techniques enable you to effectively design and analyse algorithms. Analysis of Algorithms: Proof of correctness: An argument that the algorithm works correctly for all inputs. Proof: A valid argument that establishes the truth of a mathematical statement. Analysis of worst-case running time as a function of the input size.

Introduction Proof: A valid argument that establishes the truth of a mathematical statement. The statements used in a proof can include axioms, definitions, the premises, if any, of the theorem, and previously proven theorems and uses rules of inference to draw conclusions. A proof technique very commonly used when proving correctness of Algorithms is Mathematical Induction. Definition (Strong Induction) To prove that P(n) is true for all positive integers, where P(n) is a propositional function, we complete two steps: Basis step: We show that P(1) is true. Inductive step: We show that for all k, if P(1), P(2),..., P(k) are true, then P(k + 1) is true.

Introduction Definition (Strong Induction) To prove that P(n) is true for all positive integers, where P(n) is a propositional function, we complete two steps: Basis step: We show that P(1) is true. Inductive step: We show that for all k, if P(1), P(2),..., P(k) are true, then P(k + 1) is true. Question: Show that for all n > 0, 1 + 3 +... + (2n 1) = n 2.

Introduction Proof Question: Show that for all n > 0, 1 + 3 +... + (2n 1) = n 2. Let P(n) be the proposition that 1 + 3 + 5 +... + (2n 1) equals n 2. Basis step: P(1) is true since the summation consists of only a single term 1 and 1 2 = 1. Inductive step: Assume that P(1), P(2),..., P(k) are true for any arbitrary integer k. Then we have: 1 + 3 +... + (2(k + 1) 1) = 1 + 3 +... + (2k 1) + (2k + 1) = k 2 + 2k + 1 (since P(k) is true) = (k + 1) 2 This shows that P(k + 1) is true. Using the principle of Induction, we conclude that P(n) is true for all n > 0.

Introduction Algorithm: A step-by-step way of solving a problem. Design of Algorithms: Algorithm is more of an art than science However, we will learn some basic tools and techniques that have evolved over time. These tools and techniques enable you to effectively design and analyse algorithms. Analysis of Algorithms: Proof of correctness: An argument that the algorithm works correctly for all inputs. Proof: A valid argument that establishes the truth of a mathematical statement. Analysis of worst-case running time as a function of the input size.

Introduction Algorithm Design Techniques Divide and Conquer Greedy Algorithms Dynamic Programming Network Flows

Introduction Material that will be covered in the course: Basic graph algorithms Algorithm Design Techniques Divide and Conquer Greedy Algorithms Dynamic Programming Network Flows Computational intractability

Introduction Divide and Conquer Some examples of Divide and Conquer Algorithms: Binary Search Median finding Multiplying numbers Merge sort, quick sort.

Introduction Greedy Algorithms Problem Interval scheduling: You have a lecture room and you get n requests for scheduling lectures. Each request has a start time and an end time. The goal is to maximise the number of lectures.

Introduction Dynamic Programming Problem Interval scheduling: You have a lecture room and you get n requests for scheduling lectures. Each request has a start time, an end time, and a price (that you will get in case the lecture is scheduled). The goal is to maximise your earnings.

Introduction Network Flows Problem Job assignment: There are n people and n jobs. Each person has a list of jobs he/she could possibly do. Find a job assignment so that: 1 each job is assigned to a different person, and 2 each person is assigned a job from his/her list.

Introduction Computational Intractability Is it always possible to find a fast algorithm for any problem? Problem Given a social network, find the largest subset of people such that no two people in the subset are friends.

Introduction Computational Intractability The problem in the previous slide is called the Independent Set problem and no one knows if it can be solved in polynomial time (quickly). There is a whole class of problems to which Independent Set belongs. If you solve one problem in this class quickly, then you can solve all the problems in this class quickly. You can also win a million dollars!! We will see techniques of how to show that a new problem belongs to this class: Why: because then you can say to your boss that the new problem belongs to the difficult class of problems and even the most brilliant people in the world have not been able to solve the problem so do not expect me to do it. Also, if I can solve the problem there is no reason for me to work for you!

Course Overview Material that will be covered in the course: Basic graph algorithms Algorithm Design Techniques Divide and Conquer Greedy Algorithms Dynamic Programming Network Flows Computational intractability

Graphs

Graphs Introduction A way to represent a set of objects with pair-wise relationships among them. The objects are represented as vertices and the relationships are represented as edges.

Graphs Introduction Examples Social networks Communication networks Transportation networks Dependency networks

Graphs Introduction Weighted graphs: There are weights associated with each edge quantifying the relationship. For example, delay in communication network.

Graphs Introduction Directed graphs: Asymmetric relationships between the objects. For example, one way streets.

Graphs Introduction Path: A sequence of vertices v 1, v 2,..., v k such that for any consecutive pair of vertices v i, v i+1, (v i, v i+1 ) is an edge in the graph. It is called a path from v 1 to v k. Cycle: A cycle is a path where v 1 = v k and v 1,..., v k 1 are distinct vertices.

Graphs Introduction Strongly connected: A graph is called strongly connected iff for any pair of vertices u, v, there is a path from u to v and a path from v to u.

Graphs Introduction Tree: A strongly connected, undirected graph is called a tree if it has no cycles. How many edges does a tree have?

Graphs Introduction Let P(n) be the statement Any tree with n nodes has exactly n 1 edges. An inductive proof will have the following steps: Base case: Show that P(1) is true. Inductive step: Show that if P(1), P(2)..., P(k) are true, then so is P(k + 1).

Graphs Introduction Let P(n) be the statement Any tree with n nodes has exactly n 1 edges. An inductive proof will have the following steps: Base case: Show that P(1) is true. Inductive step: Show that if P(1), P(2)..., P(k) are true, then so is P(k + 1). Proof outline Base case: P(1) is true since any tree with 1 vertex has 0 edges. Inductive step: Assume that P(1),..., P(k) are true. Now, consider any tree T with k + 1 vertices. Claim 1: There is a vertex v in T that has exactly 1 edge. Consider the tree T obtained by removing v and its edge from T. Claim 2: T is a tree with k vertices. As per the induction hypothesis, T has k 1 edges. This implies that T has k edges.

Graphs Introduction Proof Base case: P(1) is true since any tree with 1 vertex has 0 edges. Inductive step: Assume that P(1),..., P(k) are true. Now, consider any tree T with k + 1 vertices. Claim 1: There is a vertex v in T that has exactly 1 edge. Proof: For the sake of contradiction, assume that there does not exist such a vertex in T. Then this means that all vertices have at least two edges incident on them. Start with an arbitrary vertex u 1 in T. Starting from u 1 use one of the edges incident on u 1 to visit its neighbor u 2. Since u 2 also has at least two incident edges, take one of the other edges to visit its neighbor u 3. On repeating this, we will (in finite number of steps) visit a vertex that was already visited. This implies that there is a cycle in T. This is a contradiction. Consider the tree T obtained by removing v and its edge from T. Claim 2: T is a tree with k vertices. Proof: T clearly has k vertices. T is strongly connected since otherwise T is not strongly connected. Also, T does not have a cycle since otherwise T has a cycle. As per the induction hypothesis, T has k 1 edges. This implies that T has k edges.

End