Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 CSE 331 Sep 19, 2016.

Similar presentations


Presentation on theme: "Lecture 9 CSE 331 Sep 19, 2016."— Presentation transcript:

1 Lecture 9 CSE 331 Sep 19, 2016

2 Mini Project choice due Sep 26

3 Gale-Shapley Algorithm
At most n2 iterations Intially all men and women are free While there exists a free woman who can propose Let w be such a woman and m be the best man she has not proposed to w proposes to m O(1) time implementation If m is free (m,w) get engaged Else (m,w’) are engaged If m prefers w’ to w w remains free Else (m,w) get engaged and w’ is free Output the engaged pairs as the final output

4 Implementation Steps (0) How to represent the input?
(1) How do we find a free woman w? (2) How would w pick her best unproposed man m? (3) How do we know who m is engaged to? (4) How do we decide if m prefers w’ to w?

5 Overall running time Init(1-4) n2 X ( Query/Update(1-4) )

6 Questions?

7 Puzzle Prove that any algorithm for the SMP takes Ω(n2) time

8 Main Steps in Algorithm Design
Problem Statement Problem Definition n! Algorithm “Implementation” Analysis Correctness Analysis

9 Reading Assignments Sec 1.1 and Chap. 2 in [KT]

10 A generic tool to abstract out problems
Up Next…. Problem Statement A generic tool to abstract out problems Problem Definition Algorithm “Implementation” Analysis

11 Relationship: Mention in other’s program
Graphs Representation of relationships between pairs of entities/elements Edge Entities: News hosts Relationship: Mention in other’s program Vertex/Node

12 Graphs are omnipresent
Airline Route maps

13 What does this graph represent?
Internet

14 And this one? Math articles on Wikipedia

15 And this one?

16 Rest of today’s agenda Basic Graph definitions

17 Paths , , Sequence of vertices connected by edges Connected
Path length 3 ,

18 Connectivity u and w are connected iff there is a path between them A graph is connected iff all pairs of vertices are connected

19 Connected Graphs Every pair of vertices has a path between them

20 Cycles Sequence of k vertices connected by edges, first k-1 are distinct ,

21

22 Formally define everything

23 Tree Connected undirected graph with no cycles

24 Rooted Tree

25 How many rooted trees can an n vertex tree have?
A rooted tree How many rooted trees can an n vertex tree have? AC’s child=SG Pick any vertex as root SG’s parent=AC Let the rest of the tree hang under “gravity”

26 Rest of Today’s agenda Prove n vertex tree has n-1 edges
Algorithms for checking connectivity


Download ppt "Lecture 9 CSE 331 Sep 19, 2016."

Similar presentations


Ads by Google