Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Haskell Language). How to separate and label clusters ( 4 direction connected components) in a 2D array? ( Haskell code will be a must :(

(Haskell Language). How to separate and label clusters ( 4 direction connected components) in a 2D array? ( Haskell code will be a must :(

For example, I have a list of list number in haskell like this:

["122221111211", "211121221121", "221211222211", "111212122112", "112121212222", "112222121211", "211211221112"]

And I want to label the connected components (4 directions)to be like this:

"1 2 2 2 2 3 3 3 3 4 5 5" "6 7 7 7 2 3 8 8 3 3 9 5" "6 6 7 10 3 3 8 8 8 8 5 5" "7 7 7 10 3 11 12 8 8 5 5 8" "7 7 13 14 13 15 16 17 8 8 8 8" "7 7 13 13 13 13 18 19 20 8 20 20" "21 7 7 13 22 22 19 19 20 20 20 23"

the color version:

image text in transcribed

the way to label the clusters is like the flood fill, if it connects (same number) to their neighbor by up-down-left-right direction, they will be grouping in the same cluster. we go from top left to bottom right. Please help me solve this problem. Thanks!!! (I have to write this by Haskell)

c 15 15 21 121 221 1 12 11 1221 1 12 1211 3.8.2 Input File 21,20, 18, 16, 12,6 1 1.1., 1,2, 1 2 2,1 1 2,1 2,2, 1,2, 1 1, 2,2,2,2, 1, 1 1,1 2, 1, 2, 1.2 1,1 1,1 2 2,1 1 2 2 2 2 1,1, 2, 2, 2,2, 1.2 1,2, 1,1 3.8.3 Submission output 1 122221 111211 2 211121221 121

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago