Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Statement: Take an integer as input that indicates the size of a dynamically allocated integer array ( one dimensional ( ID ) ) .
Problem Statement:
Take an integer as input that indicates the size of a dynamically allocated integer array one
dimensional ID The array contains positive integers and Take all the elements of the
array as input. You have to split the elements of the array based on Keep the splitted elements
as the rows of a dynamically allocated twodimensional D array and print the elements of the
array. Finally sort each row of the D array and print the elements of the D array again.
Procedure: The rightmost values inside third lhracket indicate marks for implementing functions
For solving the problem, you have to implement the functions prototyped below:
int" twodimensionalint "ara, int int "totalrows, int "sizesofeachrow
ara: ID integer array that contains positive integers and
: the size of the ara
totalrows: the reference to the number of rows of the newly generated D array
sizesofeachrow: integer array D that stores the sizes of the D arrays
indicating the rows of the generated array
This function will return the generated array.
void PrintingDint arad int "sizesofeachrow, int rows
arad: integer array
sizesofeachrow: integer array D that stores the sizes of the D arrays
indicating the rows of arad
rows: The number of rows of arad
This function is for printing the contents of arad
void sortingDint arad int "sizesofeachrow, int rows
arad: integer array
sizesofeachrow: integer array ID that stores the sizes of the ID arrays
indicating the rows of ara
rows: The number of rows of arad
This function will sort each row elements of ara separately
Restrictions:
To access an element or to define array size, you can't use array indexingdefining with
operator. In other words, your code mustn't contain any third bracket
You have to use dynamic memory allocation for each array you use and free them when
they are no longer needed. While allocating memory, be careful to efficiently allocate the
memory.
Please first calculate the amount of memory required and then allocate just the needed
amount. Allocation of a constant big amount of memory will result in a penalty.
You are not allowed to change the function prototypes.
cannot be the st or last element of the input D array. Also cannot occur side by
side inside the input D array.
Sample InputsOutputs:
Explanation:
Consider the second test case.
The first line denotes the size of the D array and the second line indicates all the elements of the
array. There is only one in the array that splits the array into a array with rows ie
row No and row No After sorting each row
separately, the rows will be and
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