Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So in this assignment, I must make 4 simple matrices and be able to do a word search using the 'void matrix_search ()' function. I

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

So in this assignment, I must make 4 simple matrices and be able to do a word search using the 'void matrix_search ()' function. I have some code already done but it is throwing me errors I can't quite wrap my head around. If anyone could write this in C++ for me and show me the code, I would be grateful! Thank you! PS: Let me know if something is not clear!

Assignment description Finding patterns in data, like text files, or arrays of pixel values, is the basis of many more advanced methods, for example, image recognition in Al, or text processing. This week, you will write a program to input and store a 2D matrix of data of user-defined size, and then find a segment of data in that matrix that matches a search key, regardless of its orientation or direction. em 3 4 5 matrix_search.h -- These are your function declarations. Do not edit this file. We will ignore or overwrite file of yours upon submission. If you change it and your whole program does not run as a result, you will receive a grade of %0. Remember, a function should ONLY do what it is stated to do, and no more. Anything else should be in main! **/ 0000 #ifndef WORD_SEARCH #define WORD_SEARCH 13 #include #include // optional with modern GCC installs using std::cout; using std::endl; using std::cin; using std::string; Writes to a string array containing: * the your (the student author's) Campus Username */ void get_identity(string &my_id); 27 Builds a two dimensional dynamic array of the given size -- rows: The number of rows in the matrix -- cols: The number of columns in the matrix -- returns a ponter to a pointer to a char, which is the pointer to the matrix. */ char ** build_matrix(int rows, int cols); 31 36 37 39 Fills a matrix from std in (command Line terminal input) -- rows: The number of rows in the matrix -- cols: The number of columns in the matrix -- **matrix: The matrix to be filled -- Should simply accept input via cin or getline, etc. -- Should only fill the matrix (not do things like discard junk input; Leave that in main if needed). */ 40 41 42 void fill_matrix(int rows, int cols, char **matrix); 47 Prints the matrix as follows (don't include extra newlines or spaces in the function; do that in main if needed): aaa aaa aaa void print_matrix(int rows, int cols, char **matrix); 55 56 1 Deletes a two dimensional dynamically allocated matrix -- rows: The number of rows in the matrix -- **matrix: the pointer to the matrix to be deleted -- What are you supposed to do with a dangling pointer? */ void delete_matrix(int rows, char **matrix); 59 60 61 A* 65 70 71 Modifies sol to contain the locations of the start and end characters of the word. -- Sol: 4-Large array of ints, where: ind : row start, ind 1: col start, ind 2: row end, ind 3: col end -- word: the word being searched for -- rows: the number of rows in the matrix -- cols: the number of columns in the matrix -- **matrix: pointer to a dynamically allocated array containing the characters to be searched -- if the solution does not exist in the matrix, set all 4 values stored in the sol array to -1 / void matrix_search(int sol[], string word, int rows, int cols, char **matrix); 73 76 #endif 80 sample_input.txt 512 Bytes 1 4 55 OUT AWN rgpgp kpofz qdxst vyryj ew y te dog 77 uc dzacy kimifze krucsip hoa w by w nmob hoy sajerix 18 wuntga x bark 15 16 17 11 11 27 brortuh avva k kweoylamhd wkfhqytyjba rh k tms q15 kq gt za yg iwtv z znoevm ymp wb rv awnclajro bxok fvwoso i 30 rjykzxctnxs 31 ag y d v pggrkc km pa iyuwreo 33 theweatherisnice 32 4 8 1 0 1 0 1 1 1 0 37 001111 0 1 38 1 0 0 1 0 1 1 0 39 11 0 1 0 1 1 1 40 111100 sample_output.txt 313 Bytes Searching for "dog" in matrix o yields: Start pos:(2, 1) to End pos:(0, 3) w Searching for "bark" in matrix 1 yields: Start pos:(4, 3) to End pos:(1, 0) Ova Searching for "theweatherisnice" in matrix 2 yields: The pattern was not found. 10 Searching for "111100" in matrix 3 yields: Start pos:(1, 5) to End pos:(1, 0) Assignment description Finding patterns in data, like text files, or arrays of pixel values, is the basis of many more advanced methods, for example, image recognition in Al, or text processing. This week, you will write a program to input and store a 2D matrix of data of user-defined size, and then find a segment of data in that matrix that matches a search key, regardless of its orientation or direction. em 3 4 5 matrix_search.h -- These are your function declarations. Do not edit this file. We will ignore or overwrite file of yours upon submission. If you change it and your whole program does not run as a result, you will receive a grade of %0. Remember, a function should ONLY do what it is stated to do, and no more. Anything else should be in main! **/ 0000 #ifndef WORD_SEARCH #define WORD_SEARCH 13 #include #include // optional with modern GCC installs using std::cout; using std::endl; using std::cin; using std::string; Writes to a string array containing: * the your (the student author's) Campus Username */ void get_identity(string &my_id); 27 Builds a two dimensional dynamic array of the given size -- rows: The number of rows in the matrix -- cols: The number of columns in the matrix -- returns a ponter to a pointer to a char, which is the pointer to the matrix. */ char ** build_matrix(int rows, int cols); 31 36 37 39 Fills a matrix from std in (command Line terminal input) -- rows: The number of rows in the matrix -- cols: The number of columns in the matrix -- **matrix: The matrix to be filled -- Should simply accept input via cin or getline, etc. -- Should only fill the matrix (not do things like discard junk input; Leave that in main if needed). */ 40 41 42 void fill_matrix(int rows, int cols, char **matrix); 47 Prints the matrix as follows (don't include extra newlines or spaces in the function; do that in main if needed): aaa aaa aaa void print_matrix(int rows, int cols, char **matrix); 55 56 1 Deletes a two dimensional dynamically allocated matrix -- rows: The number of rows in the matrix -- **matrix: the pointer to the matrix to be deleted -- What are you supposed to do with a dangling pointer? */ void delete_matrix(int rows, char **matrix); 59 60 61 A* 65 70 71 Modifies sol to contain the locations of the start and end characters of the word. -- Sol: 4-Large array of ints, where: ind : row start, ind 1: col start, ind 2: row end, ind 3: col end -- word: the word being searched for -- rows: the number of rows in the matrix -- cols: the number of columns in the matrix -- **matrix: pointer to a dynamically allocated array containing the characters to be searched -- if the solution does not exist in the matrix, set all 4 values stored in the sol array to -1 / void matrix_search(int sol[], string word, int rows, int cols, char **matrix); 73 76 #endif 80 sample_input.txt 512 Bytes 1 4 55 OUT AWN rgpgp kpofz qdxst vyryj ew y te dog 77 uc dzacy kimifze krucsip hoa w by w nmob hoy sajerix 18 wuntga x bark 15 16 17 11 11 27 brortuh avva k kweoylamhd wkfhqytyjba rh k tms q15 kq gt za yg iwtv z znoevm ymp wb rv awnclajro bxok fvwoso i 30 rjykzxctnxs 31 ag y d v pggrkc km pa iyuwreo 33 theweatherisnice 32 4 8 1 0 1 0 1 1 1 0 37 001111 0 1 38 1 0 0 1 0 1 1 0 39 11 0 1 0 1 1 1 40 111100 sample_output.txt 313 Bytes Searching for "dog" in matrix o yields: Start pos:(2, 1) to End pos:(0, 3) w Searching for "bark" in matrix 1 yields: Start pos:(4, 3) to End pos:(1, 0) Ova Searching for "theweatherisnice" in matrix 2 yields: The pattern was not found. 10 Searching for "111100" in matrix 3 yields: Start pos:(1, 5) to End pos:(1, 0)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions