algorithms and data structures · 2020. 12. 1. · y. watanobe, j. huang, y. pei, w. chen, q. zhao,...

36
. . . . . . 1/1 Algorithms and Data Structures 5th Lecture: Divide and Conquer Yutaka Watanobe, Jie Huang, Yan Pei, Wenxi Chen, Qiangfu Zhao, Wanming Chu University of Aizu Last Updated: 2020/12/1 Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures

Upload: others

Post on 23-Jan-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 1/1

Algorithms and Data Structures5th Lecture: Divide and Conquer

Yutaka Watanobe, Jie Huang, Yan Pei,Wenxi Chen, Qiangfu Zhao, Wanming Chu

University of Aizu

Last Updated: 2020/12/1

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 2: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 2/1

Outline

RecursionDivide and Conquer ApproachMerge Sort

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 3: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 3/1

Recursion

A recursive function is a function which calls itself recursively.The recursive function should be terminated by a specifiedcondition.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 4: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 4/1

Recursive Function: An Example

toBinary(x)

if x > 0

toBinary(x/2)

print x%2

call toBinary(input)

Input

86

Output

1010110

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 5: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 5/1

Divide and Conquer Approach

Many useful algorithms are recursive in structure: to solve agiven problem, they call themselves recursively one or moretimes to deal with closely related subproblems.These algorithms typically follow a divide and conquer approach:

1 [Divide] they break the problem into several subproblems that aresimilar to the original problem but smaller in size,

2 [Conquer] solve the subproblems recursively, and then3 [Combine] combine these solutions to create a solution to the

original problem.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 6: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 6/1

Divide and Conquer Algorithm: An Example

Recursive divide and conquer solution for finding the maximum.

findMax(A, left, right)

m = (left + right)/2

if left == right-1

return A[left]

else

u = findMax(A, left, m)

v = findMax(A, m, right)

if u > v

return u

else

return v

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 7: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 7/1

Finding the Maximum

4 1 8 5 9 1 2

0 1 2 3 4 5 6

4 1 8 5 9 1 2

0 1 2 3 4 5 6

4 1 8

0 1 2

1 8

1 2

5 9 1 2

3 4 5 6

5 9 1 2

3 4 5 6

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 8: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 8/1

Analysis

findMax(A, left, right)

m = (left + right)/2

if left == right-1

return A[left]

else

u = findMax(A, left, m)

v = findMax(A, m, right)

if u > v

return u

else

return v

const

const

const

T(n/2)

T(n/2)

const

const

const

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 9: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 9/1

Recurrence

When an algorithm contains a recursive call to itself, its runningtime can often be described by a recurrence equation orrecurrence, which describes the overall running time on aproblem of size n in terms of the running time on smaller inputs.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 10: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 10/1

Analysis of Finding the Maximum

We set up recurrence for Finding the Maximum.1 [Divide] The divide step computes the middle of subarray, which

takes constant time. Thus, O(1).2 [Conquer] We recursively solve two subproblems, each of size

n/2, which contributes 2T (n/2) to the running time.3 [Combine] The comparison between two maximum values in two

n-element subarrays takes time O(1).

The recurrence for the worst-case running time T (n) of Findingthe Maximum is

T (n) ={

c (n = 1)2T (n/2) + c (n > 1)

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 11: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 11/1

Solving Recurrence

The algorithm takes linear time.

T (n) = 2T (n/2) + c= 2(2T (n/4) + c) + c= 2(2(2T (n/8) + c) + c) + c

...

= 2(2(...(2T (1) + c)...) + c) + c= 2(2(...(2c + c)...) + c) + c= (2n − 1)c

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 12: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 12/1

Merge Sort

The Merge Sort algorithm closely follows the divide and conquerparadigm. Intuitively, it operates as follows.

1 [Divide] Divide the n-element sequence to be sorted into twosubsequences of n/2 elements each.

2 [Conquer] Sort the two subsequences recursively using MergeSort.

3 [Combine] Merge the two sorted subsequences to produce thesorted answer.

The key operation of the Merge Sort algorithm is the merging oftwo sorted sequences in the [Combine] step.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 13: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 13/1

Merge Sort: Merge

merge(A, l, m, r)

n1 = m - l

n2 = r - m

create an array L[0..n1]

create an array R[0..n2]

for i = 0 to n1-1

L[i] = A[l+i]

for j = 0 to n2-1

R[j] = A[m+j]

L[n1] = SENTINEL

R[n2] = SENTINEL

i = 0

j = 0

for k = l to r-1

if L[i] < R[j]

A[k] = L[i]

i = i+1

else

A[k] = R[j]

j = j+1

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 14: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 14/1

Variables for Merge

i j

k

1 5 4 8∞ 2 ∞

A

L R

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 15: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 15/1

Merge

0 1 2 0 1 32

1. 2. 3.

4. 5.

1 5 4 8∞ 2 ∞

A

L R

1 5 2 4 8 1 5 2 4 8 1 5 2 4 8

1 5 2 4 8 1 5 2 4 8

1 1 2 1 2

1 2 1 2

4

4 4 5 85

1 5 2 4 8∞ ∞ 1 5 2 4 8∞ ∞ 1 5 2 4 8∞ ∞

1 5 2 4 8∞ ∞ 1 5 2 4 8∞ ∞

1 5 2 4 81 2 4 5 8

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 16: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 16/1

Merge (0)

0 1 2 0 1 32

1 5 4 8∞ 2 ∞

1 5 2 4 8A

L R

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 17: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 17/1

Merge (1)

1.

1 2 4 81

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 18: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 18/1

Merge (2)

2.

1 5 4 81 2

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 19: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 19/1

Merge (3)

3.

1 5 2 4 81 2 4

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 20: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 20/1

Merge (4)

4.

1 5 2 4 81 2 4 5

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 21: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 21/1

Merge (5)

5.

1 5 2 4 81 2 4 5 8

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 22: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 22/1

Merge (6)

1 5 2 4 81 2 4 5 8

1 5 2 4 8∞ ∞

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 23: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 23/1

Merge (7)

1 5 2 4 81 2 4 5 8

1 5 2 4 8∞ ∞

1

234 5

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 24: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 24/1

Merge Sort

mergeSort(A, left, right)

if left + 1 < right

mid = (left + right)/2

mergeSort(A, left, mid)

mergeSort(A, mid, right)

merge(A, left, mid, right)

To sort the entire sequence A = (A[0],A[1], ...,A[n − 1]), wemake the initial call mergeSort(A, 0, n).

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 25: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 25/1

Variables for the Merge Sort Algorithm

8 9 1110 12 13 14 15 1716 1918 20 21 22

mid rightleft

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 26: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 26/1

Merge Sort

Divide Conquer9 6 7 2 5 1 8

9 6 7 2 5 1 8

9 6 7 2

7 4

6 9

5 2

2 7

2 6 7 9

5 1

69 1

1 5

1 2 4

1 2 2 4 5 6 7

69 27 15 8

1

2

3 4

5

6

7 8

9

10

4 2 8 9

4 2 5 8

8 4 2 2 4 8

4 2 2 4

9 124

11

12

13 14

15

16

1718

19 20

21

22

23

24

The operation of Merge Sort on the arrayA = {9,6,7,2,5,1,8,4,2}. The lengths of the sorted sequencesbeing merged increase as the algorithm progresses from bottomto top.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 27: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 27/1

Merge Sort (1-5)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2

9 6

7 4

6 9

69

1

2

3 4

5

4 2

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 28: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 28/1

Merge Sort (6-8)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2

9 6 7 2

7 4

6 9

5 269 27

1

2

3 4

5

6

7 8

4 2

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 29: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 29/1

Merge Sort (9-10)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2

9 6 7 2

7 4

6 9

5 2

2 7

2 6 7 9

69 27

1

2

3 4

5

6

7 8

9

10

4 2

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 30: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 30/1

Merge Sort (11-15)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2 5 1 8

9 6 7 2

7 4

6 9

5 2

2 7

2 6 7 9

5 1

9 1

1 5

69 27 15

1

2

3 4

5

6

7 8

9

10

4 2

4 2

11

12

13 14

15

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 31: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 31/1

Merge Sort (16-20)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2 5 1 8

9 6 7 2

7 4

6 9

5 2

2 7

2 6 7 9

5 1

69 1

1 5

69 27 15 8

1

2

3 4

5

6

7 8

9

10

4 2

4 2

8 4 2

4 2

9 124

11

12

13 14

15

16

1718

19 20

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 32: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 32/1

Merge Sort (21-24)

Divide Conquer9 6 7 2 5 1 8

9 6 7 2 5 1 8

9 6 7 2

7 4

6 9

5 2

2 7

2 6 7 9

5 1

69 1

1 5

1 2 4

1 2 2 4 5 6 7

69 27 15 8

1

2

3 4

5

6

7 8

9

10

4 2 8 9

4 2 5 8

8 4 2 2 4 8

4 2 2 4

9 124

11

12

13 14

15

16

1718

19 20

21

22

23

24

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 33: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 33/1

Analysis of Merge Sort (1)

We set up recurrence for Merge Sort.1 [Divide] The divide step computes the middle of subarray, which

takes constant time. Thus, O(1).2 [Conquer] We recursively solve two subproblems, each of size

n/2, which contributes 2T (n/2) to the running time.3 [Combine] The Merge procedure on an n element subarray takes

time O(n)

The recurrence for the worst-case running time T (n) of MergeSort is

T (n) ={

c (n = 1)2T (n/2) + cn (n > 1)

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 34: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 34/1

Analysis of Merge Sort (2)

T(n) cn cn

T(n/2) T(n/2) cn/2 cn/2

T(n/4) T(n/4) T(n/4) T(n/4)

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 35: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 35/1

Analysis of Merge Sort (3)

cn

cn/2 cn/2

T(n/4) T(n/4) T(n/4) T(n/4)

c c c c c c c c

log n

cn

cn

cn

cn

n Total: cn log n + cn

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures

Page 36: Algorithms and Data Structures · 2020. 12. 1. · Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu Algorithms and Data Structures. . . . . . 6/1 Divide

. . . . . . 36/1

Reference

1 Introduction to Algorithms (third edition), Thomas H.Cormen,Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. TheMIT Press, 2012.

Y. Watanobe, J. Huang, Y. Pei, W. Chen, Q. Zhao, W. Chu University of Aizu

Algorithms and Data Structures