Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions