After "sorting" a 2D array, we can easily obtain the largest and the smallest elements of a 2D array. Let us look at the following analysis: Given 2D 273 367 680 654 51 135 151 432 492 502 293 358 65 612 412 681 465 765 265 150 593 647 54 665 Sarted roW 2D 273 654 135 432 492 150 593 65 151 293 680 465 612 367 681 647 765 665 358 51 54 265 412 502 Tranpose of 2D 358 593 654 680 681 51 54 150 273 293 367 65 135 465 647 151 432 612 765 265 412 492 502 665 Sorted row 2D again 65 135 293 367 51 150 273 465 647 54 265 412 492 612 358 593 654 680 681 765 151 432 502 665 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 an 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)

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
After "sorting" a 2D array, we can easily obtain the largest and the smallest elements of a 2D array. Let us look at the
following analysis:
Given 2D
273 367
680
293
358
150
593
654
135
681
465
51
65
647
612
412
151
432
765
265
54
492
502
665
Sarted row 2D
150
273
293
680
465
612
502
367
358
593
65
654
135
432
492
681
647
765
665
51
54
265
151
412
Tranpose of 2D
358
51
54
265
412
492
502
665
150
593
273 654
680
681 647
65
135
465
151
432
612
765
293
367
Sorted row 2D again
51
150
273
465
647
65
135
293
367
151
432
502
665
54 265 358
593
654
680
765
412
492
612
681
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
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.
array,
i.e.,
Let us now look at the following UML diagram: (Note that additional methods are allowed; proposed methods and
instance variable cannot be changed)
Transcribed Image Text:After "sorting" a 2D array, we can easily obtain the largest and the smallest elements of a 2D array. Let us look at the following analysis: Given 2D 273 367 680 293 358 150 593 654 135 681 465 51 65 647 612 412 151 432 765 265 54 492 502 665 Sarted row 2D 150 273 293 680 465 612 502 367 358 593 65 654 135 432 492 681 647 765 665 51 54 265 151 412 Tranpose of 2D 358 51 54 265 412 492 502 665 150 593 273 654 680 681 647 65 135 465 151 432 612 765 293 367 Sorted row 2D again 51 150 273 465 647 65 135 293 367 151 432 502 665 54 265 358 593 654 680 765 412 492 612 681 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 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. array, i.e., Let us now look at the following UML diagram: (Note that additional methods are allowed; proposed methods and instance variable cannot be changed)
O TwoD
- int00 a
Exam_Q3
O + TwoD(int00 a)
•+ TwoD(TwoD td)
- static void construct2D(intN a)
O + static void main(Stringl args)
O+void sortRow0
O+void transpose0
O+void display2DO
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).
Transcribed Image Text:O TwoD - int00 a Exam_Q3 O + TwoD(int00 a) •+ TwoD(TwoD td) - static void construct2D(intN a) O + static void main(Stringl args) O+void sortRow0 O+void transpose0 O+void display2DO 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).
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