Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the implementation of List class by fixed size array approach, please write codes for the three member functions: constructor , insert , and retrieve

For the implementation of List class by fixed size array approach, please write codes for the three member functions: constructor, insert, and retrieve (marked red in the class declaration).

The class List is defined as follows:

//The List preserves the order of the elements

public class List{

private final T[] items;

private int size; // number of items in the list

private static final int DEFAULT_CAPACITY=20;

//Default constructor

public List() {

//TO DO

}

// To check if the list is empty or not

public boolean isEmpty() {

return size<=0;

}

// To get the length of the list

public int getLength() {

return size;

}

//To insert the newItem into the list at position index

//NOTE: 0<=index<=getlength()

public boolean insert(int index, T newItem) {

//TO DO

}

//To remove an item from the list at position index

//NOTE: 0<=index

public boolean remove(int index) {

//DONE

}

// To retrieve a list item by position index

// If 0<=index

public T retrieve(int index) {

//TO DO

}

}

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago