Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

kindly resolve the question below and clarify how the text file with the blob can be read to a string array without character spaces. Your

kindly resolve the question below and clarify how the text file with the blob can be read to a string array without character spaces.

image text in transcribed

image text in transcribed

image text in transcribed

Your job for this program is to use recursion to count the number of "blobs" in a 2D array. You will be given a text file containing a 2D matrix of O's and *'s. A blob is connected group of *'s. The *'s are connected if they are von Neumann neighbors (top, bottom, left or right). Follow the guidelines below. . Use constants for the number of rows and the number of columns. You will be given a 20 x 20 text file, but it is beneficial to store a border of O's around the actual blob world to make the search for blobs on the edges much easier; i.e. make your array 22 x 22 and store the blob world in locations 1..20, 1..20. Prompt the user for a filename to read in a given text file containing O's and *'s. Scan through the 2D matrix. When you find the beginning of a blob, call a recursive function that will replace all of the *'s in the blob with #'s. Print the original blob world and the mutated blob world as shown in the example. Do not print the border of O's around the actual world. Count the number of blobs found and print the total count under the worlds as shown in the example. Example: *** Your output heading and explanation of program should be here **** Original world: 0 eeeeee . eeeee @.@.@ .. . eee.ee eee. ..@@ eee ... . 0. 0.0 eeeee. @ World with mutated blobs: @#@@#@@@ eeee eeeeeeeee # #@# ee# # eeeee eeeeeeeeeee # # een #eeeeet eeeeeeeee ## eee eeee # 56 blobs were found. Program 1 Hints: If you are programming in c++, remember to include the following libraries: iostream (for reading file names from keyboard), fstream (for file reading/writing), and string (for string input/output). Either create a border of O's (character 0, not integer 0) or check for out-of- bounds before calling recursive function. IMPORTANT: Read in and print out the world before you do anything else. If you use a border of O's, remember that nested loops processing and printing should go from 1 to n-1 (with the exception of initializing the world). Scanning the 2D array is a nested loop; not recursive. This can be in the main or in a function. If an asterisk, *, is encountered, count the blob and call the recursive function, processBlob (or whatever you want to name it). processBlob, should be sent the 2D array and a specific position (row & col value). The base case for the recursive function is implied (do nothing). If an is found, it should be replaced with #and only if an * is found, make 4 recursive calls, one for each von Neumann neighbor. Start programming soon. This program is somewhat tricky. Ask for help if needed. a

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions