Docsity

Condensed Matter- General Physics, Lecture notes of Physics

Toggle sidebar
bg1
1
Revision on L2
•Greedy principle: always make a locally best (greedy) action for
constructing a solution.
•Two Problems:
1) Interval scheduling: maximize the number of jobs one can do.
2) Interval partitioning: minimizing the number of classrooms.
•Algorithms:
1) sorting all the jobs (lectures) in the increasing order of finish (start)
time.
2) select jobs one by one constrained by feasibility.
arrange lectures one by one, don’t open new classrooms unless
necessary.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download Condensed Matter- General Physics and more Lecture notes Physics in PDF only on Docsity!

Revision on L

  • (^) Greedy principle: always make a locally best (greedy) action for

constructing a solution.

  • (^) Two Problems:

1) Interval scheduling: maximize the number of jobs one can do.

2) Interval partitioning: minimizing the number of classrooms.

  • (^) Algorithms:

1) sorting all the jobs (lectures) in the increasing order of finish (start)

time.

2) select jobs one by one constrained by feasibility.

arrange lectures one by one, don’t open new classrooms unless

necessary.

  • (^) Proofs:

-Interval scheduling:

Let G be the optimal solution returned by greedy algorithm

Let OPT be an optimal solution.

Gradually change OPT to G without hurting its quality.

  • (^) Interval partitioning:

Define “depth” and show that the number of classrooms >=depth.

Show the number of classrooms used in greedy method<=depth.

Therefore, G is optimal.

  • (^) Graph
    • (^) Subgraph
  • (^) Tree: 1) connected, and
    1. no cycle/unique path between two nodes/the no of edges=the no of nodes -1.
  • (^) Forest:
    • (^) a disjoint union of trees/a graph without cycles.

Problem: Rail Network

Better Approach

Minimize the total length of the railway connecting all the

towns

Definition of MST

Spanning tree: A subgraph T of a undirected

and connected graph G=(V, E) is a spanning

tree of G if

1. T is a tree and

2. T contains all the nodes of G.

Minimum Spanning Tree: Example

  • (^) Example: The graph has 16 spanning trees. Some are: The graph has two minimum spanning trees, each with a length of 6:

Growing a MST(Generic Algorithm)

  • (^) Set A is always a subset of some minimum spanning tree. This property is called the invariant property.
  • (^) An edge (u, v) is a safe edge for A if adding it to A does not destroy the invariant. A is always part of a minimum spanning tree GENERIC_MST(G, w) 1 A:={} 2 while A does not form a spanning tree do 3 find an edge (u,v) that is safe for A 4 A:=A∪{(u,v)} 5 return A

V-S↓

a

b

h

c d

e

g f

i

4 8 7 9 10 14 4 2 2 6 1 7 11 7 S↑ (^) ↑ S ↓ V-S

  • (^) This figure shows a cut (S,V-S) of the graph. S={a, b, d, e}, V-S={h, i, g, c, f}
  • (^) The edge (d,c) and (a, h) are two light edges crossing the cut.

Theorem

If

  • (^) G=(V, E) is a connected and undirected graph with a nonnegative real-valued

length function w defined on E.

  • (^) A is a subset of E that is included in a minimum spanning tree (MST) for G.
  • (^) (S,V-S) is a cut of G such that no edge in A crosses the cut.
  • (^) (x, y) is a light edge crossing (S,V-S).

Then , edge (x, y) is safe for A (i.e. A (x,y) is part of a MST too)

Outline of Pf : Let T opt

be a MST (blue) that includes A.

Case 1: (x,y) is in Topt , then A (x,y) is in Topt , so (x,y) is safe.

Case 2: (x, y) is not in Topt (as in the Figure, red edge is (x,y) )

  • (^) There MUST be a path linking x and y in T

opt, then there is a another edge (x’,

y’) (blue) which crosses (S, V-S) and is in this path.

  • (^) We replace (x’, y’) in T

opt by (x, y) and get another tree T’opt

  • (^) Since (x, y) is light , T’

opt is also optimal.

  • (^) A (x,y) is in T’

opt , so (x,y) is safe.^

x y x’ y’

The algorithms of Kruskal and Prim

  • (^) The two algorithms are elaborations of the generic algorithm.
  • (^) They each use a specific rule to determine a safe edge in line 3 of GENERIC_MST.
  • (^) In Kruskal's algorithm,
    • (^) The set A is a forest.
    • (^) The safe edge added to A is always a least-weight edge in the graph that connects two distinct components.
  • (^) In Prim's algorithm,
    • (^) The set A forms a single tree.
    • (^) The safe edge added to A is always a least-weight edge connecting the tree to a vertex not in the tree.

Kruskal’s Algorithm

A

B C

D

E

F

G

H

I

J

Graph

A

B C

D

E

F

G

H

I

J

A B A D

B B

B

C D

J C

C

E

F

D

D H

J E G

F G F I

G I G J

H J I J