Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 2 Write a static method public static boolean is Sorted (int[] a) that checks whether each one-dimensional sub-array of a two-dimensional array is sorted

image text in transcribed
Task 2 Write a static method public static boolean is Sorted (int[] a) that checks whether each one-dimensional sub-array of a two-dimensional array is sorted in increasing order. For instance, for int[u a = {{1, 2, 3, 4, 5, 5}, {2, 3, 4}}; the method should return true (since the two sub-arrays are sorted). Likewise for the empty array intnb = {}; it should return true (since all subarrays -- which means for the empty array, none has to be checked - are sorted). But for int[] c = {{1}, {2, 1, 3, 4}}; it should return false (since the subarray {2, 1, 3, 4} is not sorted). You may write (an) auxiliary method(s). Test your program with the three examples above in a main method. Also, comment your code to explain the main parts of your logic. [25 marks)

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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions