Question: in java I need an insert method: public void insert (int n) The insert method is supposed to the following. 1. Insert an integer into
in java
I need an insert method:
public void insert (int n)
The insert method is supposed to the following.
1. Insert an integer into the list so the list is maintained in ascending order.
2. Not insert a duplicate value
3. If the array is full, then the value should be inserted (if not a duplicate) and the last value dropped off the end of the array
For example:
The current array: 0 0 0 0 0
insert(1);
output : 1 0 0 0 0
insert(3);
output: 1 3 0 0 0
insert(2);
output: 1 2 3 0 0
If the array is full:
The current array : 1 2 3 4 5
insert(6);
output: 1 2 3 4 6
Do not sort the array after insertion. Not sorting method is allowed inside the insert method. Please.
I have made this question really clear. If you are not able to solve my problem, do not copy from somewhere else, and waste my time. Thank you.
I will rate immediately, if your answer follows my problem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
