Richard Anderson Lecture 4

Slides:



Advertisements
Similar presentations
Graphs: basic definitions and notation Definition A (undirected, unweighted) graph is a pair G = (V, E), where V = {v 1, v 2,..., v n } is a set of vertices,
Advertisements

Edited by Malak Abdullah Jordan University of Science and Technology Data Structures Using C++ 2E Chapter 12 Graphs.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
 Graph Graph  Types of Graphs Types of Graphs  Data Structures to Store Graphs Data Structures to Store Graphs  Graph Definitions Graph Definitions.
CSE 421 Algorithms Richard Anderson Lecture 4. What does it mean for an algorithm to be efficient?
Asymptotic Analysis Motivation Definitions Common complexity functions
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
CSE 321 Discrete Structures Winter 2008 Lecture 25 Graph Theory.
Lecture 13 CSE 331 Oct 2, Announcements Mid term in < 2 weeks Graded HW2 at the END of the class.
CSE 421 Algorithms Richard Anderson Lecture 3. Classroom Presenter Project Understand how to use Pen Computing to support classroom instruction Writing.
9.2 Graph Terminology and Special Types Graphs
GRAPH Learning Outcomes Students should be able to:
CSCI 256 Data Structures and Algorithm Analysis Lecture 4 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
© 2006 Pearson Addison-Wesley. All rights reserved14 A-1 Chapter 14 Graphs.
Algorithms Growth of Functions. Some Notation NNatural numbers RReal numbers N + Positive natural numbers R + Positive real numbers R * Non-negative real.
General rules: Find big-O f(n) = k = O(1) f(n) = a k n k + a k-1 n k a 1 n 1 + a 0 = O(n k ) Other functions, try to find the dominant term according.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 2.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 6.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Graph Concepts Elif Tosun 252a-aa (All graphics created by using demo/graphwin/gw*)
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 4.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Graph Concepts Illustrated Using The Leda Library Amanuel Lemma CS252 Algorithms.
CSC 252: Algorithms October 28, 2000 Homework #5: Graphs Victoria Manfredi (252a-ad) notes: -Definitions for each of the graph concepts are those presented.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
Graphs David Kauchak cs302 Spring Admin HW 12 and 13 (and likely 14) You can submit revised solutions to any problem you missed Also submit your.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. 1 Chapter 22 Graphs and Applications.
CSC 252 Pallavi Moorthy Homework 5. 1.) Vertices, edges From cd../../handout/demo/graph_alg/gw_shortest_path.
Asymptotic Complexity
Chapter 28 Graphs and Applications
Chapter 3: Growth of Functions
Lecture 12 Graph Algorithms
CSE 421: Introduction to Algorithms
CS120 Graphs.
Chapter 3: Growth of Functions
Planarity Testing.
Asymptotic Notations Algorithms Lecture 9.
CSE 421: Introduction to Algorithms
Lecture 12 CSE 331 Sep 26, 2016.
Chapter 2: Fundamentals of the Analysis of Algorithm Efficiency
Lecture 13 CSE 331 Oct 1, 2012.
Chapter 22: Elementary Graph Algorithms I
Lectures on Graph Algorithms: searching, testing and sorting
Elementary Graph Algorithms
Richard Anderson Lecture 3
Chapter 2.
CSE 421: Introduction to Algorithms
Richard Anderson Autumn 2016 Lecture 5
Lecture 12 CSE 331 Sep 28, 2012.
Lecture 12 CSE 331 Sep 26, 2011.
Chapter 14 Graphs © 2006 Pearson Addison-Wesley. All rights reserved.
CSE 332: Data Abstractions Leftover Asymptotic Analysis
Richard Anderson Winter 2009 Lecture 6
Lecture 11 CSE 331 Sep 19, 2014.
Lecture 11 CSE 331 Sep 21, 2017.
Lecture 12 CSE 331 Sep 22, 2014.
GRAPHS G=<V,E> Adjacent vertices Undirected graph
Chapter 16 1 – Graphs Graph Categories Strong Components
Lecture 11 CSE 331 Sep 22, 2016.
Richard Anderson Winter 2019 Lecture 4
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Elementary Graph Algorithms
Richard Anderson Winter 2019 Lecture 6
Richard Anderson Lecture 5 Graph Theory
Lecture 15 CSE 331 Oct 4, 2010.
Richard Anderson Winter 2019 Lecture 5
Big Omega, Theta Defn: T(N) = (g(N)) if there are positive constants c and n0 such that T(N)  c g(N) for all N  n0 . Lingo: “T(N) grows no slower than.
Richard Anderson Autumn 2015 Lecture 4
Richard Anderson Autumn 2015 Lecture 6
Intro to Theory of Computation
Presentation transcript:

Richard Anderson Lecture 4 CSE 421 Algorithms Richard Anderson Lecture 4

Announcements Homework 2, Due October 11, 1:30 pm. Reading Chapter 2.1, 2.2 Chapter 3 (Mostly review) Start on Chapter 4

Today Finish discussion of asymptotics Graph theory terminology O, W, Q Graph theory terminology Basic graph algorithms

Formalizing growth rates T(n) is O(f(n)) [T : Z+  R+] If n is sufficiently large, T(n) is bounded by a constant multiple of f(n) Exist c, n0, such that for n > n0, T(n) < c f(n) T(n) is O(f(n)) will be written as: T(n) = O(f(n)) Be careful with this notation

Order the following functions in increasing order by their growth rate n log4n 2n2 + 10n 2n/100 1000n + log8 n n100 3n 1000 log10n n1/2

Ordering growth rates For b > 0 and x > 0 logbn is O(nx) For r > 1 and d > 0 nd is O(rn)

Lower bounds T(n) is W(f(n)) Warning: definitions of W vary T(n) is at least a constant multiple of f(n) There exists an n0, and e > 0 such that T(n) > ef(n) for all n > n0 Warning: definitions of W vary T(n) is Q(f(n)) if T(n) is O(f(n)) and T(n) is W(f(n))

True or False n log n is O(n2) n3 is O(4n3 + 2n + n) n-1 is O(n-2) n-1 is W(n-2) f(n) = n2 if n is even, 0 if n is odd f(n) is W(n2)

Useful Theorems If lim (f(n) / g(n)) = c for c > 0 then f(n) = Q(g(n)) If f(n) is O(g(n)) and g(n) is O(h(n)) then f(n) is O(h(n)) If f(n) is O(h(n)) and g(n) is O(h(n)) then f(n) + g(n) is O(h(n))

Graph Theory G = (V, E) Undirected graphs Directed graphs Explain that there will be some review from 326 Graph Theory G = (V, E) V – vertices E – edges Undirected graphs Edges sets of two vertices {u, v} Directed graphs Edges ordered pairs (u, v) Many other flavors Edge / vertices weights Parallel edges Self loops By default |V| = n and |E| = m

Definitions Path: v1, v2, …, vk, with (vi, vi+1) in E Distance Simple Path Cycle Simple Cycle Distance Connectivity Undirected Directed (strong connectivity) Trees Rooted Unrooted

Graph search Find a path from s to t S = {s} While there exists (u, v) in E with u in S and v not in S Pred[v] = u Add v to S if (v = t) then path found

Breadth first search Explore vertices in layers s in layer 1 Neighbors of s in layer 2 Neighbors of layer 2 in layer 3 . . . s

Key observation All edges go between vertices on the same layer or adjacent layers 1 2 3 4 5 6 7 8

Bipartite A graph V is bipartite if V can be partitioned into V1, V2 such that all edges go between V1 and V2 A graph is bipartite if it can be two colored Two color this graph

Testing Bipartiteness If a graph contains an odd cycle, it is not bipartite

Algorithm Run BFS Color odd layers red, even layers blue If no edges between the same layer, the graph is bipartite If edge between two vertices of the same layer, then there is an odd cycle, and the graph is not bipartite