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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education