Structural Verification Structural verification is, in this case, validating that a data structure is formed according to its specification. For this lab you are given an essentially arbitrary specification, but you could think of this being used to verify a data structure produced by a program that must have certain properties in order to be used correctly. For example, a list must not be circular, or an image file might require a particular header describing its contents. You must implement this function, which examines a matrix and ensures that it adheres to the following specification: bool verify_matrix(int x, int y, int **matrix); This function accepts an X dimension, a Y dimension, and a matrix of y rows and columns; although it is declared as int **, this is the same type of matrix as returned by parse_life() in PA1, and you should access it as a two-dimensional array. Note that it is stored in Y-major orientation; that is, matrix ranges from matrix[0][0] to matrix[y-1][× - 1] (again, as in PA1). You should verify the following properties: • The matrix is square. That is, its x dimension and y dimension are the same. Because there is no way in C to determine the size of an array, your function must consult its x and y arguments to verify this. • Every row in the matrix is sorted in non-decreasing order. This means that every element of each row is greater than or equal to the element in the previous index. • The first element of every row forms a sequence sorted in non-decreasing order. Like the individual rows, every element in the first column is greater than or equal to the element in the previous index. Your function should return true if the matrix satisfies these properties, and false if it does not. Your function most not attempt to access any array element that is outside of the specified dimensions — even if those dimensions are non-square.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question
Structural Verification
Structural verification is, in this case, validating that a data structure is formed according to its specification. For this
lab you are given an essentially arbitrary specification, but you could think of this being used to verify a data structure
produced by a program that must have certain properties in order to be used correctly. For example, a list must not
be circular, or an image file might require a particular header describing its contents.
You must implement this function, which examines a matrix and ensures that it adheres to the following specification:
bool verify_matrix(int x, int y, int **matrix);
This function accepts an X dimension, a Y dimension, and a matrix of y rows and x columns; although it is
declared as int **, this is the same type of matrix as returned by parse_life() in PA1, and you should access it as
a two-dimensional array. Note that it is stored in Y-major orientation; that is, matrix ranges from matrix[0][0] to
matrix[y 1][x - 1] (again, as in PA1).
You should verify the following properties:
• The matrix is square. That is, its x dimension and y dimension are the same. Because there is no way in C to
determine the size of an array, your function must consult its × and y arguments to verify this.
• Every row in the matrix is sorted in non-decreasing order. This means that every element of each row is greater
than or equal to the element in the previous index.
• The first element of every row forms a sequence sorted in non-decreasing order. Like the individual rows, every
element in the first column is greater than or equal to the element in the previous index.
Your function should return true if the matrix satisfies these properties, and false if it does not. Your function
most not attempt to access any array element that is outside of the specified dimensions — even if those dimensions
are non-square.
Transcribed Image Text:Structural Verification Structural verification is, in this case, validating that a data structure is formed according to its specification. For this lab you are given an essentially arbitrary specification, but you could think of this being used to verify a data structure produced by a program that must have certain properties in order to be used correctly. For example, a list must not be circular, or an image file might require a particular header describing its contents. You must implement this function, which examines a matrix and ensures that it adheres to the following specification: bool verify_matrix(int x, int y, int **matrix); This function accepts an X dimension, a Y dimension, and a matrix of y rows and x columns; although it is declared as int **, this is the same type of matrix as returned by parse_life() in PA1, and you should access it as a two-dimensional array. Note that it is stored in Y-major orientation; that is, matrix ranges from matrix[0][0] to matrix[y 1][x - 1] (again, as in PA1). You should verify the following properties: • The matrix is square. That is, its x dimension and y dimension are the same. Because there is no way in C to determine the size of an array, your function must consult its × and y arguments to verify this. • Every row in the matrix is sorted in non-decreasing order. This means that every element of each row is greater than or equal to the element in the previous index. • The first element of every row forms a sequence sorted in non-decreasing order. Like the individual rows, every element in the first column is greater than or equal to the element in the previous index. Your function should return true if the matrix satisfies these properties, and false if it does not. Your function most not attempt to access any array element that is outside of the specified dimensions — even if those dimensions are non-square.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning