iven 2D 273 367 293 0 150 680 654 358 681 593 65 465 647 151 432 612 765 54 492 502 412 265 665 51 135 prted row 2D 0 150 273 293 367 358 593 654 680 681 51 65 135 465 647 54 151 432 612 765 265 412 492 502 665 ranpose of 2D o 358 51 54 265

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

You can see in the above display, we first sort each row of the 2D array; we then take the transpose of a two D array, i.e., all the row elements becoming the column elements; we then sort each row of the 2D again. If you read the final array, each row is sorted; each column is also sorted. The smallest element obviously is the 1st element of the two D array and the last element is the largest element of a two D array.

Let us now look at the following UML diagram: (Note that additional methods are allowed; proposed methods and instance variable cannot be changed)

 

Main method firstly constructs a 2D array of certain sizes and then construct a TwoD object and drive the task according to the above runtime interactions and displays.

TwoD class has only one instance variable which is a two D array of numbers ( int or double). The constructor must do some “deep” copying.  A copy constructor. The other three methods are obvious in definition: to sort each row, to rotate the 2D array (i.e., change 1st row to 1st column, 2nd row to 2nd column etc.); and to display the 2D array (explore the use of nested enhanced for loops).

Given 2D
273 367
680 654 358 681 593
51 135 65 465 647
151 432 612 765
492 502 412 265 665
293
0 150
54
Sarted row 2D
O 150 273 293 367
358 593 654 680 681
51
54 151 432 612 765
265 412 492 502 665
65 135 465 647
Tranpose of 2D
o 358 51
54 265
150 593 65 151 412
273 654 135 432 492
293 680 465 612 502
367 681 647 765 665
Sorted row 2D_again
O 51 54 265 358
65 150 151 412 593
135 273 432 492 654
293 465 502 612 680
367 647 665 681 765
Transcribed Image Text:Given 2D 273 367 680 654 358 681 593 51 135 65 465 647 151 432 612 765 492 502 412 265 665 293 0 150 54 Sarted row 2D O 150 273 293 367 358 593 654 680 681 51 54 151 432 612 765 265 412 492 502 665 65 135 465 647 Tranpose of 2D o 358 51 54 265 150 593 65 151 412 273 654 135 432 492 293 680 465 612 502 367 681 647 765 665 Sorted row 2D_again O 51 54 265 358 65 150 151 412 593 135 273 432 492 654 293 465 502 612 680 367 647 665 681 765
TwoD
1-int00 a
Exam_Q3
+ TwoD(int0 a)
+ TwoD(TwoD td)
+ void sortRow)
+ void transpose0
- static void construct2D(int] a)
+ static void main(String] args)
O+void display2D0
Transcribed Image Text:TwoD 1-int00 a Exam_Q3 + TwoD(int0 a) + TwoD(TwoD td) + void sortRow) + void transpose0 - static void construct2D(int] a) + static void main(String] args) O+void display2D0
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY