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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started