1. Trang chủ
  2. » Thể loại khác

Cấu trúc dữ liệu và giải thuật - Hien M. Nguyen CTDL 12 Minh hoa 1

13 126 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 13
Dung lượng 239,51 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Cấu trúc dữ liệu và giải thuật - Hien M. Nguyen CTDL 12 Minh hoa 1 tài liệu, giáo án, bài giảng , luận văn, luận án, đồ...

Trang 1

Lecture slides by Kevin Wayne

Copyright © 2005 Pearson-Addison Wesley

Copyright © 2013 Kevin Wayne

5 D IVIDE AND C ONQUER I

‣ merge and count demo

Trang 2

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

sorted list A sorted list B

Trang 3

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 2 and add x to inversion count

sorted list A sorted list B

sorted list C

Trang 4

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 3 and decrement x

2 11 16 17 23

sorted list A sorted list B

2

sorted list C

5

Trang 5

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 7 and decrement x

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

5

Trang 6

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 10 and decrement x

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

5

Trang 7

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 11 and add x to increment count

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

5

Trang 8

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 14 and decrement x

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Trang 9

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 16 and add x to increment count

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Trang 10

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 17 and add x to increment count

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Trang 11

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

compare minimum entry in each list: copy 18 and decrement x

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Trang 12

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

list A exhausted: copy 23

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Trang 13

Given two sorted lists A and B,

・Merge A and B into sorted list C.

Merge and count demo

done: return 9 inversions

2 11 16 17 23

3 7 10 14 18

sorted list A sorted list B

sorted list C

Ngày đăng: 17/12/2017, 19:27

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w