Assignment #2 (Assignment due: Nov. 06, 2018) v1 v2 v3 v4 v5

Slides:



Advertisements
Similar presentations
Sorting Really Big Files Sorting Part 3. Using K Temporary Files Given  N records in file F  M records will fit into internal memory  Use K temp files,
Advertisements

Topological Sort and Hashing
Graph Algorithms: Topological Sort The topological sorting problem: given a directed, acyclic graph G = (V, E), find a linear ordering of the vertices.
Elementary Graph Algorithms Depth-first search.Topological Sort. Strongly connected components. Chapter 22 CLRS.
Lecture 16: DFS, DAG, and Strongly Connected Components Shang-Hua Teng.
Graph Theory, DFS & BFS Kelly Choi What is a graph? A set of vertices and edges –Directed/Undirected –Weighted/Unweighted –Cyclic/Acyclic.
CSE 2331/5331 Topic 11: Basic Graph Alg. Representations Undirected graph Directed graph Topological sort.
Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
1 Graphs: Traversal Searching/Traversing a graph = visiting the vertices of a graph by following the edges in a systematic way Example: Given a highway.
Graph traversals / cutler1 Graph traversals Breadth first search Depth first search.
16a-Graphs-More (More) Graphs Fonts: MTExtra:  (comment) Symbol:  Wingdings: Fonts: MTExtra:  (comment) Symbol:  Wingdings:
CS 473Lecture 151 CS473-Algorithms I Lecture 15 Graph Searching: Depth-First Search and Topological Sort.
Implementation of Graph Decomposition and Recursive Closures Graph Decomposition and Recursive Closures was published in 2003 by Professor Chen. The project.
1 Data Structures DFS, Topological Sort Dana Shapira.
CSE 780 Algorithms Advanced Algorithms Graph Alg. DFS Topological sort.
Lecture 10 Graph Algorithms. Definitions Graph is a set of vertices V, with edges connecting some of the vertices (edge set E). An edge can connect two.
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
Spring 2015 Lecture 10: Elementary Graph Algorithms
CS261 – Recitation 5 Fall Outline Assignment 3: Memory and Timing Tests Binary Search Algorithm Binary Search Tree Add/Remove examples 1.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
Topological Sort (an application of DFS) CSC263 Tutorial 9.
1 Chapter 22 Elementary Graph Algorithms. 2 Introduction G=(V, E) –V = vertex set –E = edge set Graph representation –Adjacency list –Adjacency matrix.
Week 12 - Monday.  What did we talk about last time?  Topological sort and cycle detection in directed graphs  Connectivity  Strong connectivity.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 20.
Topological Sort: Definition
Answers to Assignment #2
1 Chapter 22: Elementary Graph Algorithms III. 2 About this lecture Topological Sort.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Topological Sort. Sorting technique over DAGs (Directed Acyclic Graphs) It creates a linear sequence (ordering) for the nodes such that: –If u has an.
Introduction to Algorithms
Topological Sorting.
Elementary Graph Algorithms
Chapter 22 Elementary Graph Algorithms
Graphs-Part II Depth First Search (DFS)
Graphs Representation, BFS, DFS
Main algorithm with recursion: We’ll have a function DFS that initializes, and then calls DFS-Visit, which is a recursive function and does the depth first.
Lecture 11 Graph Algorithms
Topics Covered after Mid-Term
CSE 2331/5331 Topic 9: Basic Graph Alg.
Topological Sort (an application of DFS)
CS200: Algorithm Analysis
Graph: representation and traversal CISC4080, Computer Algorithms
More Graph Algorithms.
Topological Sort.
Topological Sort.
Graphs Graph transversals.
Elementary Graph Algorithms
Graph Algorithms – 2 DAGs Topological order
Graph Representation Adjacency list representation of G = (V, E)
Lecture 10 Algorithm Analysis
Graphs Lecture 18 CS2110 – Fall 2009.
Graph Algorithms – 2.
Advanced Algorithms Analysis and Design
Advanced Algorithms Analysis and Design
"Learning how to learn is life's most important skill. " - Tony Buzan
Topological Ordering Algorithm: Example
Topological Sort CSE 373 Data Structures Lecture 19.
Graph Representation (23.1/22.1)
Directed Acyclic Graphs && Topological Sorting
Topological Sort (an application of DFS)
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Topological Ordering Algorithm: Example
Topological Ordering Algorithm: Example
CSE 417: Algorithms and Computational Complexity
Richard Anderson Lecture 5 Graph Theory
Lecture 11 Graph Algorithms
Topological Ordering Algorithm: Example
Chapter 22: Elementary Graph Algorithms III
Presentation transcript:

Assignment #2 (Assignment due: Nov. 06, 2018) v1 v2 v3 v4 v5 1.(30) See the graph G shown in Fig. 1(a), which can be stored in a file on disk as a set of pairs as shown in Fig. 1(b). Design an algorithm to load the file in main memory and store it as a set of linked lists. (The algorithm should be able to be used for any graph.) (v1, v2) (v1, v3) (v1, v4) (v1, v5) (v2, v3) (v2, v4) (v2, v5) (v3, v4) (v3, v5) (v4, v5) v1 v2 v3 v4 v5 (a) (b) Fig. 1 Each pair represents an edge.

Assignment #2 v1 v1 v2 v2 v3 v4 v3 v5 v4 v5 2.(30) Another way to perform topological sorting on a directed acyclic graph G = (V, E) is to repeatedly find a node of in-degree 0, output it, and remove it and all of its outgoing edges from the graph. Explain how to implement this idea so that it runs in time O(|V| + |E|). 3.(40) Consider the graph G shown in Fig. 1(a) once again. Its DFS tree T is shown in Fig. 2(a), in which each node v is associated with (d[v], f[v]). Remember that a node is a descendant of another node v in T if d[v] < d[u]) < f[u] < f[v]). v1 (1, 10) v1 (1, 10) v2 (2, 9) (2, 9) v2 v3 v4 v3 (a) (3, 6)(7, 8) v5 (b) (7, 8) (3, 6) v4 v5 (4, 5) (3, 6) (4, 5) Fig. 2 Describe an algorithm that associates each node v in G with a sequence s of pairs (as shown in Fig. 2(b)) such that u is a descendant of v in G if and only if d[v] < d[u]) < f[u] < f[v]), or there exists a pair p = (a, b) in s with a  d[u]) < f[u]  b.