Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need a quick answer (java programming), please Activity 1 (Portfolio Task): Implement recursively the Sierpinski carpet. More specifically, a recursive function will take as
I need a quick answer (java programming), please
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 3n3n, where 1 n5 (i.e. 33,99,2727,8181,243243 ). The 2D array can be divided into 9 sub-arrays of size 3n13n1, e.g. a 33 array can be divided into 9 sub-arrays of size 1x1: 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 99 array: First, remove the middle 33 sub-array: Then, apply the process recursively on the 8 sub-arrays of size 33 (removing arrays of size 11 ): For an array of size 2727, the Sierpiski carpet would be as follows (remove 99 sub-array, then 33 sub-arrays, and then 11 sub-arrays): The array or characters is initialised by setting each cell to , while removing a subarray sets the corresponding cells to ' '. File 'Sierpinski_Carpet.zip' contains a Sierpiski carpet for sizes 33,99,2727,8181 and 243243 (in case sizes 8181 and 243243 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 Sierpiski carpet Discuss your progress with your Tutor during practical sessions. What to include in your Portfolio: Report: Describe in your report which parts of Activity 1 have been successfully implemented IntelliJ Project: Include your Java code for Activity 1 in your IntelliJ project under package "Practical_20Step 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