#include<iostream>
#include<cstring>
using namespace std;
char a[10][100001]=cfw_0;
int change(char de)cfw_
if (de >= '0' )&(de <='9') return de -'0' ;
if (de >= 'A' )&(de <='F') return de -'A'+10;
;
void work2(int l, int beg, int end)cfw_
for (int j =
Lecture 5. Dynamic Connectivity
and Minimum Spanning Tree
Algorithm Analysis and Design, IIIS, Tsinghua
In this lecture
!
Worst-case dynamic connectivity in (m1/2)
!
!
!
!
Improves to (n1/2) by sparsification
Generalizes to minimum spanning tree
Decrement
Lecture 12. A Brief Introduction to
Expander Graph
Algorithm Design and Analysis, IIIS, Tsinghua
Random walk
!
!
In an undirected (or directed) graph, can the random walk
from s reach t?
Random walk:
! Start at s.
! Let di be the degree of the current nod
Lecture 10. More on Min-Cut
Algorithm Design and Analysis, IIIS, Tsinghua
Tree packing
!
An unweighted tree packing is a set of edge-disjoint
spanning trees of the graph
Tree packing
!
An unweighted tree packing is a set of edge-disjoint
spanning trees of
Lecture 6. Min-Cut and Edge
Connectivity
Algorithm Design and Analysis, IIIS, Tsinghua
In this lecture
!
!
!
!
!
We consider min-cut problem for undirected unweighted
graphs
Kargers algorithm: randomized (n2) for min-cut
Stoer and Wagner algorithm: determ
Lecture 8. Algorithms with FMM for
Shortest Path and Bottleneck Path
Algorithm Design and Analysis, IIIS, Tsinghua
!
Matrix Multiplication can be applied to many algorithms
for dense graphs:
Problem
Running time
Authors
Transitive closure
O(n)=O(n2.38)
tr
Lecture 1. Complexity of Union-Find
Data Structure
Algorithm Design and Analysis, IIIS, Tsinghua
Union-Find Problem
Given a set cfw_1, 2, , n of n elements
! Initially each element is in a different set
!
!
cfw_1, cfw_2, , cfw_n
An intermixed sequence of
Lecture 7 Some Primal-Dual
Relaxation Methods
Design and Analysis of Algorithms, IIIS, Tsinghua
Todays lecture
!
!
!
Approximation algorithm for Constrained Steiner forest
Gabow-Tarjans O(mn1/2log(nW) algorithm for maximum
weight perfect matching in bipar
Algorithm Analysis and Design-PROBLEM SET 2
November 9, 2016
Due November 24th. Upload to learn.tsinghua.edu.cn
Problem 1
m) worst-case update
Suppose we have a dynamic minimum spanning tree structure with O(
n),
time. We can also use the technique of s
Algorithm Analysis and Design-PROBLEM SET 1
October 13, 2016
Due October 26th. Upload to learn.tsinghua.edu.cn
Problem 1
Consider the Tarjans offline lowest common ancestor algorithm. Given a rooted tree T , the
lowest common ancestor of two nodes u and v
Lecture 11. Computing Market
Equilibriums
Algorithm Design and Analysis, IIIS, Tsinghua
Irving Fisher, 1891
!
Defined a fundamental
market model
!
Special case of Walras
model
Several buyers with
different utility functions and moneys.
Several buyers with
#include<iostream>
#include<cstring>
using namespace std;
char a[10][100001]=cfw_' ';
int s[500001] = cfw_0;
int s2[500001] = cfw_0;
void work(int k)cfw_
int l;
l = strlen(a[k]);
for ( int j = 0; j<l ; j+)cfw_
int dig = 0 ;
if (a[k][j] >= '0' )&(a[k]
NP-Completeness
Bin Wang
School of Software
Tsinghua University
April 8, 2014
Polynomial time
NP-completeness
Outline
1
Polynomial time
Polynomial time decision
Polynomial-time verification
2
NP-completeness
NP-completeness and reducibility
NP-completenes
String Matching
Bin Wang
School of Software
Tsinghua University
April 1, 2014
The String Matching problem
The String Matching Algorithms
Outline
1
The String Matching problem
Overview
Notation and terminology
2
The String Matching Algorithms
The nave stri
Sorting Algorithms
Bin Wang
School of Software
Tsinghua University
March 4, 2014
Heapsort
Quicksort
Outline
1
Heapsort
2
Quicksort
3
Sorting in Linear Time
Lower bounds for sorting
Counting sort
Radix sort
Bucket Sort
Sorting in Linear Time
Heapsort
Quick
Amortized Analysis &
Fibonacci Heaps
Bin Wang
School of Software
Tsinghua University
March 25, 2014
Dynamic tables
Aggregate analysis
The accounting method
Outline
1
Dynamic tables
2
Aggregate analysis
3
The accounting method
4
The potential method
5
Fibo
Dynamic Programming
Bin Wang
School of Software
Tsinghua University
March 11, 2014
Rod cutting
Matrix-chain multiplication
Elements of DM
Outline
1
Rod cutting
2
Matrix-chain multiplication
3
Elements of DM
4
LCS
5
Optimal binary search trees
LCS
Optimal
Approximation Algorithms
Bin Wang
School of Software
Tsinghua University
April 8, 2014
Overview
Vertex-cover problem
TSP
Set-covering problem
Outline
1
Overview
2
Vertex-cover problem
3
TSP
4
Set-covering problem
5
Randomization and LP
6
Subset-sum proble
Foundations
Bin Wang
School of Software
Tsinghua University
February 25, 2014
Course Information Getting Started Growth of Functions
Recurrences Divide and Conquer
Outline
1
Course Information
2
Getting Started
3
Growth of Functions
4
Recurrences
5
Divide
Greedy Algorithms
Bin Wang
School of Software
Tsinghua University
March 18, 2014
An activity-selection problem
Elements of the greedy strategy
Huffman codes
Matroids
Outline
1
An activity-selection problem
2
Elements of the greedy strategy
3
Huffman codes
Lecture 2. Fibonacci Heap and its
Application
Algorithm Design and Analysis, IIIS, Tsinghua
Priority Queues
Supports the following operations.
Insert element x.
Return min element.
Return and delete minimum element.
Decrease key of element x to k.
Applica