For this assignment, you will create an implementation of the ArrayListADT inter
ID: 668789 • Letter: F
Question
For this assignment, you will create an implementation of the ArrayListADT interface (below). A 'list' is a sequence of values, which may include duplicates. The ordering of the items in the list is not specified but does matter, and is in fact problem dependent. No insertion ever occurs at an arbitrary location. When an item is removed from the list, the ordering of the remaining elements in the list is unchanged. There may not be any empty or unused cells between the front and rear of the list.
Your implementation of the ArrayListADT offers a meaningful improvement over basic arrays for list-based operations. Inserting or removing an element at index [0] is a timeconsuming operation for arrays. If you wish to insert an element at index [0] and the array is not empty, then you must shift all of the existing elements out of the way before the insertion can occur. Similarly, if you remove the element at index [0] from a non-empty array, you must shift elements down to 'fill in the hole'. Your implementation must be able to insert or remove elements from either end of the array in constant time, with no shifting of elements necessary. A circular array strategy offer this capability. "Circular" is an abstraction; the underlying array doesn't form a circle but rather will be a standard linear array.
A solution to this problem can be found if you abandon the notion that the first element in the list must be at index [0]. Instead, you maintain a class level variable that hold the index of the 'front' and 'rear' of the list. The front and rear indices move independently, allowing insertion and deletion to happen without shifting anything.
This list (in order) is: 4, 9, 12, 7, 8, 3, 6, 10. The 'front' and 'rear' indices simply wrap around when they run off the end.
We want to segregate our data structures and separate them from any application programs. Accordingly, you must place all data structures in a package nameddata_structures. Your ArrayLinearList class must implement the LinearListADT interface. Your project will consist of exactly the following two files, both of which must be in a data_structures/ package:
LinearListADT.java The linear list interface (provided below)
ArrayLinearList.java Your implementation of the this interface
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Explanation / Answer
ArrylistADT circular
fornt ane rear of a circular of F and R
A array a consisiting of N (array size)
elements passed and element is passed in function that will be inserted at the rear of queue.
[overflow]
if(F=3 abd R=N)
OR
(R+1=F)
then write('OVERFLOW')
return
[Resert rear pointer]
if(R=N)
OR
(R=NULL)
then set R-1
setQ[R]-Y
else
ser R-R+1
set Q[R]-Y
[Is property set]
if F=NULL
then f-1
return
cQ(F,R,Q,N)
F and R is Front and Rear of circular
q consisting N elemtnes
1[underflow?]
if F=NULL
then write('underflow')
return
[delete the element]
set Y-Q[F]
[set front pointer properly}
if F=R
then
set F-R-NULL
else
F=N
then set F-1
else
set F-F+1
return
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.