Question: Task 2 ( Number of different ( sorted ) ) Create the method public static int numberUnlikeSorted ( int [ ] a ) . If
Task Number of different sorted
Create the method public static int numberUnlikeSortedint a If the table a is not sorted in ascending
order, the method must throw an IllegalStateException with the appropriate text. If a is sorted in ascending
order, the method must output how many different numbers are in the table.
The table a can have the same values, or can only have different values. If for example, we have int
the method should return since there are different values in the table.
The method must not change the table's content. The method must return if the table is empty. An
empty table should not give an error message.
Task Number of different unsorted
Create the method public static int numberUnsortedint a The table a can now be any integer table, it
does not have to be sorted, and can have several equal values.
The method should return how many different values are in a and should not
change the table's contents.
The method should not use any auxiliary tables. All work must only take place
within the table a You cannot, for example, create a sorted copy of a or create a
table of previously recorded values. You can of course create auxiliary variables.
Exercise Part sorting
Create the method public static void partsortingint a It should split the table a into two sorted parts.
The left part must contain all the odd numbers sorted, and the right part all the even numbers sorted. The
following example shows the area of use:
int; subsorta; Now we should
have
The table a can be empty, can contain both negative and positive numbers, can consist of
only odd numbers, or only of only even numbers. None of these possibilities should give an
error message.
The method must not use auxiliary tables. All work must only take place inside
table a You can of course use auxiliary variables.
The method must be designed so that it is relatively effective. One of the tests will measure efficiency
on large tables.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
