



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Solutions to exam questions related to shortest paths with multiplicative costs, increasing flow in a network using the distance labeling algorithm, and the correctness of equations in the differential cost representation used by the path sets data structure. It also discusses the time complexity of dinic's algorithm and the wave method on unit networks.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!
Be neat and concise, but complete.
One way to do this is to replace the original costs by their logarithms and then use a standard shortest path algorithm on the graph with the transformed costs. The result distances must then be transformed back to give the multiplicative distances. Since the logarithm of a product is equal to the sum of the logarithms, this procedure yields the shortest multiplicative paths. Alternatively, one can modify the original algorithms to replace expressions of the form dist(u) + length(u,v) with dist(u) * length(u,v) in the shortest path algorithm. The correctness of this follows from the logarithm transformation. Positive edge costs less than 1 reduce path lengths and have the same effect as negative edge lengths in the standard problem. If such edges are present, Dijkstra’s algorithm cannot be used.
CS 541 – Algorithms and Programs
1
s
f
e
c
t
h g
b
a
d
5,
0
2
3
3
(^2 )
2
4 (^3) 2,
3,
6,5 (^) 7,
7,
8,2 2,
6,2 (^) 5, 2, 3,0 4,
1,
2,
2,
1,
3,
1
s
f
e
c
t
h g
b
a
d
5,
0
2
3
3
(^2 )
2
4 (^3) 2,
3,
6,5 (^) 7,
7,
8,2 2,
6,2 (^) 5, 2, 3,0 4,
1,
2,
2,
1,
3,
The augmenting path is shown in bold and the modified distance labels are also shown in bold. The augmenting path has a residual capacity of 1.
1
f
e
c
t
h g
b
a
d
5,
0
2
5
(^4) 2,
3,
6,5 (^) 7, 6
7, 3
2, 8, 3
6,2 (^) 5, 2,
3, 1 4,
1,
2,
2,
1, 1
s 3,
1
f
e
c
t
h g
b
a
d
5,
0
2
5
(^4) 2,
3,
6,5 (^) 7, 6
7, 3
2, 8, 3
6,2 (^) 5, 2,
3, 1 4,
1,
2,
2,
1, 1
s 3,
4,
∆ min , ∆ cost
b d t
e c
a
1,0 0,
3,0 0,0 (^) 96,
n
g
m (^) 3,
0,
4,
i
s f h
k
2,
5,
3,
1,0 0,
4,
∆ min , ∆ cost
b d t
e c
a
1,0 0,
b (^) 3,0 d 0,0 t 96,
e c
a
b d t
e c
a
1,0 0,
3,0 0,0 (^) 96,
n
g
m (^) 3,
0,
4,
i
s f h
k
2,
5,
3,
1,0 0,
The actual tree appears at right. The edge from d to c is the only one that becomes saturated after 4 units of flow are added to the path skfebadct.
b
t
d
e
c
a
6
f
s
k
g^4
5
5
6
5
6
8
103
4
i
h
5
2
n
m
3
7
b
t
d
e
c
a
b
t
d
e
c
a
6
f
s
k
gg^44
5
5
6
5
6
8
103
4
i
h
5
2
i
h
5
2
n
m
3
7
n
m
3
7
s (^) t
complete bipartite graph with 2 n /3 vertices and edge capcities all equal to 1.
n − 2 n /3 − 2 vertices and edge capcities equal to n^2.
edge capcities equal to n^2.
edge capcities equal to n^2.
The standard version of Dinic’s algorithm will find n/3 ^2 paths in this level graph and for each path it will retrace the path at the left, meaning
of Dinic’s algorithm will run in O(n 2 log n) time, since it can effectively traverse the long path at left in O(log n) time using the dynamic trees data structure.
s (^) t
complete bipartite graph with 2 n /3 vertices and edge capcities all equal to 1.
n − 2 n /3 − 2 vertices and edge capcities equal to n^2.
edge capcities equal to n^2.
edge capcities equal to n^2.
The standard version of Dinic’s algorithm will find n/3 ^2 paths in this level graph and for each path it will retrace the path at the left, meaning
of Dinic’s algorithm will run in O(n 2 log n) time, since it can effectively traverse the long path at left in O(log n) time using the dynamic trees data structure.
From the analysis of Dinic’s algorithm on unit networks, we know that the number of blocking steps required to find a maximum flow is O(n 1/2^ ). This applies to the wave method as well. Since the wave method finds a blocking flow in O(n 2 ) time, the overall running time is O(n 5/2^ ), which is better than the O(n 3 ) for general graphs, but not as good as the O(mn 1/2^ ) that the standard version of Dinic’s algorithm achieves on unit networks.
concat ( L 1 , L 2 ) Combine the list L 1 with the list L 2.
chop ( x ) Separate the list containing x into two lists, one containing all elements preceding x and one containing x and all elements following it.
reverse ( L ) Reverse the order of the elements in list L.
tail ( L ) Return the last element of the list containing L.
These operations can be implemented efficiently using a self-adjusting binary search tree to represent each list, supplemented with a flip bit at each node. If the sum of the flip bits on the path from a node to the root of the tree is even, then the left subtree of a node x contains items that appear before x in its list and the right subtree contains items that appear after x in its list. If the sum is odd, the left subtree contains items that appear after x in its list and the right subtree contains items that appear before it. Fill in the C++ code needed to implement the reverse, tail and concat operations. You need not show how the rotate operations are modified to handle the flip bits. class listset { int n; // lists defined on items 1..n struct node { int flip; // flip bit item parent; // parent in search tree item lc; // left child item rc; // right child } *vec; // vector of nodes public:... };
item listset::reverse(list L){ vec[L].flip = !vec[L].flip; };