งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

Island Problem • Given a bitmap of aerial photographer of archipelago (chain of islands) – Bitmap is black & white • White means land • Black means sea.

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "Island Problem • Given a bitmap of aerial photographer of archipelago (chain of islands) – Bitmap is black & white • White means land • Black means sea."— ใบสำเนางานนำเสนอ:

1 Island Problem • Given a bitmap of aerial photographer of archipelago (chain of islands) – Bitmap is black & white • White means land • Black means sea • Find the largest possible square land

2 Island Problem • Input – 2D array of boolean called “Land” • Size m x n • Land[x][y] is true means location x,y is a land • Output – x,y the top-left coordinate of the largest square land and s, the size of the largest square land

3 Example 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 (0,0) Y-axis x-axis

4 Example : Some of 2x2 square 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 2x2

5 Solution : The largest square 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 4 x 4

6 Example 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 3x3

7 Sub-problem • What should be our subproblem? – Smaller maps? – Divide maps by half? – Smaller square?

8 Sub-problem • What if we find all possible square? – How the solution of n x n square constitute the solution of (n+1) x (n+1)?

9 Sub-problem 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 3x3 Land here

10 Sub-problem 0000000011 0000010000 0110001110 0111101110 0111101110 0011110011 0111110011 0011110000 1011111100 0001000000 1x1 Land here 2x2 1x1

11 Recursion • b2[x][y] ขนาดของสี่เหลี่ยมจัตุรัสใหญ่ที่สุด ที่มี มุมล่างขวาอยู่ที่ตำแหน่ง x,y (input คือ Land[x][y], m, n) • Biggest[x,y] = – Min(Biggest[x+1,y+1], Biggest[x,y+1], Biggest[x+1,y ]) + 1 if Land[x,y] – 0if not land[x,y]

12 Sub-problem 0000000011 0000010000 0210003210 0232102210 0132101110 0043210021 0133210011 0022210000 1011111100 0001000000


ดาวน์โหลด ppt Island Problem • Given a bitmap of aerial photographer of archipelago (chain of islands) – Bitmap is black & white • White means land • Black means sea.

งานนำเสนอที่คล้ายกัน


Ads by Google