Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.

Slides:



Advertisements
Similar presentations
Lecture 15. Graph Algorithms
Advertisements

Chapter 23 Minimum Spanning Tree
Single Source Shortest Paths
Some Graph Algorithms.
CSCE 411H Design and Analysis of Algorithms Set 8: Greedy Algorithms Prof. Evdokia Nikolova* Spring 2013 CSCE 411H, Spring 2013: Set 8 1 * Slides adapted.
Instructor Neelima Gupta Table of Contents Graph Algorithms Thanks to: Sunaina Kalucha (29) (MCS '11)
Minimum Spanning Trees Definition Two properties of MST’s Prim and Kruskal’s Algorithm –Proofs of correctness Boruvka’s algorithm Verifying an MST Randomized.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
F00 pq 1 Priority Queues Review the abstract data type Priority Queues Review different implementation options.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 13 Minumum spanning trees Motivation Properties of minimum spanning trees Kruskal’s.
Minimum Spanning Tree Algorithms
CSE 780 Algorithms Advanced Algorithms Minimum spanning tree Generic algorithm Kruskal’s algorithm Prim’s algorithm.
Minimum Spanning Trees Definition Algorithms –Prim –Kruskal Proofs of correctness.
Data Structures Heaps and Graphs i206 Fall 2010 John Chuang Some slides adapted from Marti Hearst, Brian Hayes, or Glenn Brookshear.
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform.
Shortest Paths Definitions Single Source Algorithms
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
Design and Analysis of Algorithms Minimum Spanning trees
Prim’s Algorithm and an MST Speed-Up
External-Memory MST (Arge, Brodal, Toma). Minimum-Spanning Tree Given a weighted, undirected graph G=(V,E), the minimum-spanning tree (MST) problem is.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Heapsort CIS 606 Spring Overview Heapsort – O(n lg n) worst case—like merge sort. – Sorts in place—like insertion sort. – Combines the best of both.
Important Problem Types and Fundamental Data Structures
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Shortest Path Algorithms. Kruskal’s Algorithm We construct a set of edges A satisfying the following invariant:  A is a subset of some MST We start with.
CS112A1 Spring 2008 Practice Final. ASYMPTOTIC NOTATION: a)Show that log(n) and ln(n) are the same in terms of Big-Theta notation b)Show that log(n+1)
1 GRAPHS - ADVANCED APPLICATIONS Minimim Spanning Trees Shortest Path Transitive Closure.
9/10/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 8 Greedy Graph.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Minimum Spanning Trees
2IL05 Data Structures Fall 2007 Lecture 13: Minimum Spanning Trees.
Spring 2015 Lecture 11: Minimum Spanning Trees
0 Course Outline n Introduction and Algorithm Analysis (Ch. 2) n Hash Tables: dictionary data structure (Ch. 5) n Heaps: priority queue data structures.
Lecture 19 Greedy Algorithms Minimum Spanning Tree Problem.
Kruskal’s and Dijkstra’s Algorithm.  Kruskal's algorithm is an algorithm in graph theory that finds a minimum spanning tree for a connected weighted.
Runtime O(VE), for +/- edges, Detects existence of neg. loops
F d a b c e g Prim’s Algorithm – an Example edge candidates choosen.
Minimum- Spanning Trees
Graphs Upon completion you will be able to:
November 22, Algorithms and Data Structures Lecture XII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
Certifying Algorithms [MNS11]R.M. McConnell, K. Mehlhorn, S. Näher, P. Schweitzer. Certifying algorithms. Computer Science Review, 5(2), , 2011.
Graph Search Applications, Minimum Spanning Tree
Elementary data structures
Spanning Trees Kruskel’s Algorithm Prim’s Algorithm
Short paths and spanning trees
Minimum Spanning Tree.
Minimum Spanning Tree.
Minimum Spanning Tree.
Graphs & Graph Algorithms 2
CSE 373 Data Structures and Algorithms
Algorithms and Data Structures Lecture XII
Dynamic Sets (III, Introduction)
Autumn 2015 Lecture 10 Minimum Spanning Trees
Minimum Spanning Tree Algorithms
Minimum Spanning Tree.
Autumn 2016 Lecture 10 Minimum Spanning Trees
CSE 417: Algorithms and Computational Complexity
The Minimum Cost Spanning Tree Problem
CSE 373: Data Structures and Algorithms
Winter 2019 Lecture 10 Minimum Spanning Trees
CSE 373: Data Structures and Algorithms
INTRODUCTION A graph G=(V,E) consists of a finite non empty set of vertices V , and a finite set of edges E which connect pairs of vertices .
Presentation transcript:

Dynamic Sets and Data Structures Over the course of an algorithm’s execution, an algorithm may maintain a dynamic set of objects The algorithm will perform operations on this set –Queries –Modifying operations We must choose a data structure to implement the dynamic set efficiently The “correct” data structure to choose is based on –Which operations need to be supported –How frequently each operation will be executed

Some Example Operations Search(S,k) Insert(S,x) Delete(S,x) Minimum or Maximum(S) Successor or Predecessor (S,x) Merge(S 1,S 2 )

Basic Data Structures/Containers Unsorted Arrays Sorted Array Unsorted linked list Sorted linked list Stack Queue Heap

Implementation Questions How can I implement a queue with two stacks? –Running time of enqueue? –Dequeue? How can I implement two stacks in one array A[1..n] so that neither stack overflows unless the total number of elements in both stacks exceeds n?

Unsorted Array Sorted Array Unsorted LL Sorted LL Heap Search Insert Delete Max/Min Pred/Succ Merge

Case Study: Dictionary Search(S,k) Insert(S,x) Delete(S,x) Is any one of the data structures listed so far always the best for implementing a dictionary? Under what conditions, if any, would each be best? What other standard data structure is often used for a dictionary?

Case Study: Priority Queue Insert(S,x) Max(S) Delete-max(S) Is any one of the data structures listed so far always the best for implementing a priority queue? Under what conditions, if any, would each be best?

Case Study: Minimum Spanning Trees Input –Weighted, connected undirected graph G=(V,E) Weight (length) function w on each edge e in E Task –Compute a spanning tree of G of minimum total weight Spanning tree –If there are n nodes in G, a spanning tree consists of n-1 edges such that no cycles are formed

Prim’s algorithm A greedy approach to edge selection –Initialize connected component N to be any node v –Select the minimum weight edge connecting N to V-N –Dynamic set implementation The nodes in V-N Value of a node is how close it is to any node in N To select minimum weight edge, choose node v with minimum value in dynamic set (Extract minimum) and add v to N When v is added to N, we need to update the value of the neighbors of v in V-N (Decrease key)

Maintain dynamic set of nodes in V-N If we started with node D, N is now {C,D} Dynamic set values of other nodes: –A, E, F: infinity –B: 4 –G: 6 Illustration ABC D EFG

Node B is added to N; edge (B,C) is added to T Need to update dynamic set values of A, E, F –Decrease-key operation Dynamic set values of other nodes: –A: 1 –E: 2 –F: 5 –G: 6 Updating Dynamic Set ABC D EFG

Node A is added to N; edge (A,B) is added to T Need to update dynamic set values of E –Decrease-key operation Dynamic set values of other nodes: –E: 2 (unchanged because 2 is smaller than 3) –F: 5 –G: 6 Updating Dynamic Set ABC D EFG

Dynamic Set Analysis How many objects in initial dynamic set representation of V-N? Time to build this dynamic set? How many extract-min operations need to happen? How many decrease-key operations may occur? Given all of the above, choose a data structure and tell me the implementation cost.