Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

***NOTE: You are requested to submit two programs: Write the program using recur

ID: 3603643 • Letter: #

Question

***NOTE: You are requested to submit two programs: Write the program using recursive functions Write the program using non-recursive functions Blob Counter: We have a two-dimensional grid of cells, each of which may be empty or filled. The filled cells that are connected form a “blob”. There may be several blobs on the grid. Write a recursive function that accepts as input the indices of a particular cell and returns the size of the blob containing the cell. There are three blobs in the sample grid below. If the function parameters represent the X and Y indices of a cell, the result of BlobCount(matrix, 2, 3) is 0; the result of BlobCount(matrix, 0, 1) is 5; the result of Blobcount(matrix, 4, 4) is 4; the result of BlobCount(matrix, 3, 0) is 2. ALGORITHM: If cell (X, Y) is not in the array then Return a count of 0. Else if cell (X,Y) is empty then Return a count of 0. Else Mark cell (X,Y) as empty. Add 1 and see whether the blob contains any of the eight neighbors of cell (X,Y). Using pointers to a matrix, write a program to read a 5x5 matrix from the user containing stars and dots. Stars represent the blob and the dots represent empty spaces. After you have finished entering the matrix, input a point on the grid (x, y). Find and print the number of cells that form a blob at the point entered. You may use the grid above as an example. Use only pointer offset notation when writing your program.

Explanation / Answer

#include #include #include using namespace std; int RandInt (int i , int j); int BlobCount (int r, int c); void getGrid(); void displayGrid(); int islands(); void horizontalborders(); int N ; char **A, **B; int *blobcounter = new int[N*N]; void main() { getGrid(); displayGrid(); cout