Array based based implementation of the List ADT: It uses an array of specific maximum length,
and storage is allocated to before run time.
public class ListArrayBased implements ListInterface
{
private static final int MAX_LIST = 50;
private Object items[];
s private int numItems;
public ListArrayBased()
{
items = new Object[MAX_LIST];
numItems = 0;
}
public boolean isEmpty()
{
return (numItems = = 0);
}
{return numItems;
}
{
if (index >= 1 && index <= numItems)
{return items[translate(index)];
}
else {throws new ListIndexOutOfBoundsException(“index OutOfRange on get”);
}
}
It is list of linear sequence of arbitary number of items together with the following procedures
like
createlist(): It is used to create an empty list
Add(index,,item)
remove(index)
isempty
get(index)
size
Solution
Array based based implementation of the List ADT: It uses an array of specific maximum length,
and storage is allocated to before run time.
public class ListArrayBased implements ListInterface
{
private static final int MAX_LIST = 50;
private Object items[];
s private int numItems;
public ListArrayBased()
{
items = new Object[MAX_LIST];
numItems = 0;
}
public boolean isEmpty()
{
return (numItems = = 0);
}
{return numItems;
}
{
if (index >= 1 && index <= numItems)
{return items[translate(index)];
}
else {throws new ListIndexOutOfBoundsException(“index OutOfRange on get”);
}
}
It is list of linear sequence of arbitary number of items together with the following procedures
like
createlist(): It is used to create an empty list
Add(index,,item)
remove(index)
isempty
get(index)
size

Array based based implementation of the List ADT It uses an array o.pdf

  • 1.
    Array based basedimplementation of the List ADT: It uses an array of specific maximum length, and storage is allocated to before run time. public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object items[]; s private int numItems; public ListArrayBased() { items = new Object[MAX_LIST]; numItems = 0; } public boolean isEmpty() { return (numItems = = 0); } {return numItems; } { if (index >= 1 && index <= numItems) {return items[translate(index)]; } else {throws new ListIndexOutOfBoundsException(“index OutOfRange on get”); } } It is list of linear sequence of arbitary number of items together with the following procedures like createlist(): It is used to create an empty list Add(index,,item) remove(index) isempty get(index) size Solution
  • 2.
    Array based basedimplementation of the List ADT: It uses an array of specific maximum length, and storage is allocated to before run time. public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object items[]; s private int numItems; public ListArrayBased() { items = new Object[MAX_LIST]; numItems = 0; } public boolean isEmpty() { return (numItems = = 0); } {return numItems; } { if (index >= 1 && index <= numItems) {return items[translate(index)]; } else {throws new ListIndexOutOfBoundsException(“index OutOfRange on get”); } } It is list of linear sequence of arbitary number of items together with the following procedures like createlist(): It is used to create an empty list Add(index,,item) remove(index) isempty get(index) size