Embed presentation
Download to read offline
![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](https://image.slidesharecdn.com/arraybasedbasedimplementationofthelistadtitusesanarrayo-230409040742-19b464fe/75/Array-based-based-implementation-of-the-List-ADT-It-uses-an-array-o-pdf-1-2048.jpg)
![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](https://image.slidesharecdn.com/arraybasedbasedimplementationofthelistadtitusesanarrayo-230409040742-19b464fe/85/Array-based-based-implementation-of-the-List-ADT-It-uses-an-array-o-pdf-2-320.jpg)
The document describes an array-based implementation of a list Abstract Data Type (ADT) in Java, encapsulated within a class called 'listarraybased'. It details key functionalities such as creating an empty list, adding and removing items, checking if the list is empty, retrieving items by index, and obtaining the size of the list. The implementation sets a maximum list size of 50 and manages elements within a predefined array.
![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](https://image.slidesharecdn.com/arraybasedbasedimplementationofthelistadtitusesanarrayo-230409040742-19b464fe/75/Array-based-based-implementation-of-the-List-ADT-It-uses-an-array-o-pdf-1-2048.jpg)
![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](https://image.slidesharecdn.com/arraybasedbasedimplementationofthelistadtitusesanarrayo-230409040742-19b464fe/85/Array-based-based-implementation-of-the-List-ADT-It-uses-an-array-o-pdf-2-320.jpg)