Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

etails our array list must be named Datalist. Start with an array with room for 10 elements. Keep all elements ontiguous (no blank places) at

image text in transcribed
etails our array list must be named Datalist. Start with an array with room for 10 elements. Keep all elements ontiguous (no blank places) at the low end of the indices. When the array is full, grow it by doubling the ize. (Do not use any built-in methods to copy the array elements. Write your own code to do this.) You o not have to shrink the array when elements are removed. The array list must have the following ublic methods (listed in UML style where GenClass is your general data class): - insert(index: int, obj: GenClass) : boolean - Inserts the given object at the given index, moving all elements up one from that index forward to make room, growing the array if necessary. If the index is out of range, the method returns false. If the object is successfully inserted, it returns true. - add(obj: GenClass): int - Adds the given object to the end of the list (the next available place in the array), gorwing the array if necessary, and returns the index where that object was added. - set(index: int, obj: GenClass) : GenClass o Replaces the object in the list at the given index with this object. If the index is out of range, the method returns null. If the operation is successful, the method returns the object that was replaced by this one. - delete(index: int) : GenClass - Deletes the object at the given index from the list, moving all elements above this index down to fill in the hole in the list. If the index is out of range, the method returns null. If the operation is successful, the method returns the object that was deleted. - removefirst(obj: GenClass) : boolean Removes the first instance of this object from the list, moving all elements above this index down to fill in the hole in the list. If the object does not exist in the list, the method returns false. If the operation is successful, the method returns true. - removeAll(obj: GenClass) : int

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

More Books

Students also viewed these Databases questions