Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello Can you please solve this for mr using IntelliJ? Activity 1 (Portfolio Task): Implement recursively the Sierpinski carpet. More specifically, a recursive function will
Hello Can you please solve this for mr using IntelliJ?
Activity 1 (Portfolio Task): Implement recursively the Sierpinski carpet. More specifically, a recursive function will take as input a 2D array of characters (i.e. char[][] board) of size 3" X 3", where 1sns 5 (i.e. 3x3, 9x9, 27x27, 81x81, 243x243). The 2D array can be divided into 9 sub-arrays of size 31-1 x 3n-1, e.g. a 3x3 array can be divided into 9 sub-arrays of size 1x1: 1 2 3 4 5 6 7 8 9 We can now remove the middle sub-array (i.e. sub-array 5) resulting in the following array: For larger arrays this process is applied recursively, e.g. a 9x9 array: First, remove the middle 3x3 sub-array: Then, apply the process recursively on the 8 sub-arrays of size 3x3 (removing arrays of size 1x1): For an array of size 27x27, the Sierpiski carpet would be as follows (remove 9x9 sub-array, then 3x3 sub-arrays, and then 1x1 sub- arrays): The array or characters is initialised by setting each cell to '*', while removing a sub-array sets the corresponding cells to ''. File Sierpinski Carpet.zip contains a Sierpinski carpet for sizes 3x3, 9x9, 27x27, 81x81 and 243x243 (in case sizes 81x81 and 243x243 are unreadable in your text editor, then you will need to reduce the font). Implement class SierpinskiCarpet, which: Stores a 2D array of characters (i.e. char[]( board) as well as the dimension size of the array (i.e. 3, 9, 27, 81 or 243) Initializes the board with characters ** Calls a recursive function that removes sub-arrays (by setting cells to ') resulting in a Sierpiski carpet (note that the recursive function must take the 2D array as input, but can take additional parameters that facilitate the recursion) Prints the Sierpinski carpet Discuss your progress with your Tutor during practical sessionsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started