Question: /* Problem 1: method isSorted [25 pts] * Given a non-empty 1D array of integers, design a method that checks * if the values in

/* Problem 1: method isSorted [25 pts]

* Given a non-empty 1D array of integers, design a method that checks

* if the values in this array are in non-decreasing order.

* Your method returns a boolean value.

This is my code for problem 1.

class isSoreted {

public static int arrayNonDecreasing(int arr[], int n) {

if (n == 1 || n == 0) return 1;

if (arr[n - 1] < arr[n - 2]) return 0;

return arrayNonDecreasing(arr, n - 1); }

public static void main(String[] args) { int arr[] = { 8, 65, 3, 99, 6, 73 }; int n = arr.length; if (arrayNonDecreasing(arr, n) != 0) System.out.println("true"); else System.out.println("false"); } }

What Junite test can I use for my method?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!