You are on page 1of 16

CS403 Algorithm Design and Analysis:

Course Content and Introduction

Satyajit Thakor
IIT Mandi

16 February, 2017
Course content

I In previous courses, you have studied some algorithms, their


implementation and the problem they are used to solve.
I In this course, the order is changed:

Problem Algorithm Design Analysis implementation


I Objective: For a given problem
I How to design an algorithm?
I How to analyze its performance?
I Implementation for hands-on experience (lab component).
I Content: design paradigms, analysis of efficiency, complexity
classes.
Textbook, attendance & evaluation

I Textbook: Algorithm Design by Jon Kleinberg and Eva Tardos,


Pearson, 2006.

I Institute attendance policy: 70% to qualify for final exam

I Assessment:
Theory (60%)
I 18% Quiz 1 (approx.)
I 18% Quiz 2 (approx.)
I 24% Final Exam (approx.)
Practical (40%)
I Lab experiments/reports/assignments/exams/viva
A word of caution

I To learn the ideas well, it is important to solve as many


problems as possible.

I Slides are not (sufficient) reading material


- They just provide a map and you cannot make a journey on a
map!
- More information will be provided during lectures and
students should also refer books to learn the subject.
Moodle

I Important: regularly visit Moodle


I Syllabus, lectures, slides, assignments
I It is also an important platform for our discussions.
I Post your queries on Moodle and I will respond to it so that
everybody will learn.
Stable matching

I Problem: Design a university admission (or industry


recruitment) process that is self-enforcing.
I Self-enforcing agreement - mutually beneficial agreement
I Students (interns) with preference for universities (firms)
I universities (firms) with preference for students (interns)

I A simpler problem: devise a system by which each of n men and


n women can end up getting married given their preferences.
I M = {m1 , . . . , mn } - set of men
I W = {w1 , . . . , wn } - set of women
I M W = {(m, w) : m M, w W } - set of all ordered pairs
Problem

I A matching S is a set of ordered pairs, such that each member


of M and each member of W appears in at most one pair in S.
I A perfect matching S 0 is a matching such that each member of
M and each member of W appears in exactly one pair in S 0 .
I Preferences: each person ranks persons of other gender.
I For example, m prefers w to w0 if m ranks w higher than w0 .
I Simplifying assumption: Ties are not allowed in the ranking.
I That is, no person is allowed to have equal preference for two or
more persons of the opposite gender.
I That is, each preference list constitute a strictly partial order.
I Can there be any issue with a perfect matching S?
Problem

I Can there be any issue with a perfect matching S?


I Consider the situation: two pairs (m, w) and (m0 , w0 ) in S such
that m prefers w0 to w, and w0 prefers m to m0 . Now what ?
I (m, w0 ) will run away! - the set of marriages S is not
self-enforcing.
I A pair (m, w0 ) is an instability with respect to S: (m, w0 ) does
not belong to S, but each of m and w0 prefers the other to their
partner in S.
I A matching S is stable if (i) it is perfect, and (ii) there is no
instability with respect to S.
I Q1: Does there exist a stable matching for every set of
preference lists?
I Q2: Given a set of preference lists, can we efficiently construct a
stable matching if there is one?
Examples

I Example 1
m prefers w to w0 , m0 prefers w to w0
w prefers m to m0 , w0 prefers m to m0

I {(m, w), (m0 , w0 )} is a unique stable matching


I {(m0 , w), (m, w0 )} is perfect but not stable.

I Example 2
m prefers w to w0 , m0 prefers w0 to w
w prefers m0 to m, w0 prefers m to m0

I {(m, w), (m0 , w0 )} is a stable matching (in favour of men)


I {(m0 , w), (m, w0 )} is also a stable matching (in favour of women)
Algorithm design
I The intuitive procedure: Gale-Shapley algorithm
Analysis

I Observation 1: w remains engaged from the point at which she


receives her first proposal; and the sequence of partners to
which she is engaged gets better and better (in terms of her
preference list).
I Observation 2: The sequence of women to whom m proposes
gets worse and worse (in terms of his preference list).

I Proposition 1: The G-S algorithm terminates after at most n2


iterations of the While loop.
I Proof [Hint: What should you be counting at each iteration?]
Analysis

I Proposition 2: If m is free at some point in the execution of the


algorithm, then there is a woman to whom he has not yet
proposed.
I Proof

I Proposition 3: The set S returned at termination is a perfect


matching.
I Proof

I Theorem 1: Consider an execution of the G-S algorithm that


returns a set of pairs S. The set S is a stable matching.
I Proof
The approach

For a given practical problem:


I formulate the problem with enough mathematical precision that
we can ask a concrete question and start thinking about
algorithms to solve it,
I design an algorithm for the problem and
I analyze the algorithm by proving it is correct and giving a
bound on the running time so as to establish the algorithms
efficiency.
Representative problems

I Interval scheduling: Given a set of jobs with start times and


finish times, find maximum cardinality subset of mutually
compatible jobs.
I Weighted interval scheduling: Given a set of jobs with start
times, finish times, and weights, find maximum weight subset of
mutually compatible jobs.
I Bipartite matching: Given a bipartite graph, find a maximum
cardinality matching.
I Independent set: Given a graph, find a maximum cardinality
independent set.
I A subset S V is independent if for every (u, v) E, either
u 6 S or v 6 S (or both).
Representative problems

I Interval scheduling: O(n log n) greedy algorithm.


I Weighted interval scheduling: O(n log n) dynamic programming
algorithm.
I Bipartite matching: O(nk ) network flow based algorithm.
I Independent set: NP-complete.

I There are problem even harder than NP-complete problems


Assignment

I We know that a stable matching is not always unique.


I Does G-S algorithm always return the same stable matching?
I Prove: Every execution of the G-S algorithm returns the same
stable matching S.
I Solved Exercises: 1, 2 (Chapter 1)
I Exercises: 3, 4, 5 (Chapter 1)

You might also like