Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN C + + Write a program that finds the minimal number of groupings in a matrix of bits. The size of a grouping is
IN C
Write a program that finds the minimal number of groupings in a matrix of bits. The size of a
grouping is determined by the number of s in it The rules in forming groups of ones are as follows:
Each group should contain the largest number of 'ones' and no blank cells.
The number of 'ones' in a group must be a power of A group can contain:
Grouping is carriedon in decreasing order meaning, one must try to group for octet first,
then for quad followed by and lastly for isolated 'ones'
COSC S
Grouping is done either horizontally or vertically or in terms of rectanglessquares Diagonal
grouping of 'ones' is not permitted.
The same elements may repeat in multiple groups only if this increases the size of the group.
The elements around the edges of the matrix, including the four corners, are adjacent and can
be grouped together.
In review:
No zeros allowed.
No diagonals.
Only power of number of cells in each group.
Groups should be as large as possible.
Every must be in at least one group.
Overlapping and wrapping around allowed.
Get the fewest number of groups possible.
Input from the keyboard the size of the rows and columns in the range Error check. The program
will randomly fill the matrix with the numbers or Output to the screen the matrix along with the
minimum number of rectangles covering the values based on the rules above. Finally, the program
should ask if the user wants to run the program again Check case Refer to the sample output below.
Sample Run:
Enter rows :
Enter cols :
COSC S
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: y
Enter rows :
Enter cols :
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: Y
Enter rows :
Enter cols :
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: y
Enter rows :
Enter cols :
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: Y
Enter rows :
Enter cols :
COSC S
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: y
Enter rows :
Enter cols :
Generated grid:
Min number of rectanglessquares formed:
Run Again YN: N
Step 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