Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1: Let's try something a little different: a two-dimensional linked list, which we'll call a matrix. This is the list analogue of a two-dimensional

image text in transcribed
image text in transcribed
Problem 1: Let's try something a little different: a two-dimensional linked list, which we'll call a matrix. This is the list analogue of a two-dimensional array. It might be useful in applications such as spreadsheet programs. For simplicity, we'll assume a singly linked approach (although a double-linked approach would probably be more appropriate for a spreadsheet). Each node (except those on the top row and left side) is pointed to by the node directly above it and by the node on its left. You can start at the upper-left node and navigate to, say, the node on the third row and fifth column by following the pointers down two rows and right four columns. Assume your matrix is created with specified dimensions entered by the useer (7 by 10, for example). You should be able to insert values in specified nodes and display the contents of the matrix. Discussion: You should create three files: Node, LLMatrix and LLMatrixApp described as follows: 1. Node class will have as variables: info of type Object, link of type Node and down of type Node (link will point to the node on the right and down will point to the node below.) 2. LLMatrix class will include the constructor given below which builds a r by c matrix with all values initialized to 0. You will need to add at least the following functions: a. Print (: displays all the values in a matrix format. b. Sum (): displays the summation of all the values in the matrix c.insert Here (Object obj, int posRow, int posCol): puts the value obj in the corresponding cell d. search (Object obj): search of obj in the matrix and returns either found or not 3. LLMatrixApp should test for all the above functions. When running the program, the tester should be able to know what operation was performed and how it affected the matrix by displaying it. Problem 1: Let's try something a little different: a two-dimensional linked list, which we'll call a matrix. This is the list analogue of a two-dimensional array. It might be useful in applications such as spreadsheet programs. For simplicity, we'll assume a singly linked approach (although a double-linked approach would probably be more appropriate for a spreadsheet). Each node (except those on the top row and left side) is pointed to by the node directly above it and by the node on its left. You can start at the upper-left node and navigate to, say, the node on the third row and fifth column by following the pointers down two rows and right four columns. Assume your matrix is created with specified dimensions entered by the useer (7 by 10, for example). You should be able to insert values in specified nodes and display the contents of the matrix. Discussion: You should create three files: Node, LLMatrix and LLMatrixApp described as follows: 1. Node class will have as variables: info of type Object, link of type Node and down of type Node (link will point to the node on the right and down will point to the node below.) 2. LLMatrix class will include the constructor given below which builds a r by c matrix with all values initialized to 0. You will need to add at least the following functions: a. Print (: displays all the values in a matrix format. b. Sum (): displays the summation of all the values in the matrix c.insert Here (Object obj, int posRow, int posCol): puts the value obj in the corresponding cell d. search (Object obj): search of obj in the matrix and returns either found or not 3. LLMatrixApp should test for all the above functions. When running the program, the tester should be able to know what operation was performed and how it affected the matrix by displaying it

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

Handbook Of Database Security Applications And Trends

Authors: Michael Gertz, Sushil Jajodia

1st Edition

1441943056, 978-1441943057

More Books

Students also viewed these Databases questions

Question

1. Outline the listening process and styles of listening

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago