List Adt Flashcards
Implementing an ArrayList involves…
private Object[] elementData
private int size
Inserting in a list involves…
Use a for loop from i < size() of the array -1
The data is shifted right
size++
Removal in a list involves…
Use a for loop from i + 1 size() - 1 are shifted left by an index size–
When an array is full the process involves…
Element data points to a new array with a size increased by 50%.
All current n elements are copied
Which ADT uses LIFO?
Stacks(Last in First Out)
Which ADT uses FIFO?
Queue(First In First out)
What is the index pointer for a circular array?
tail = (head + size - 1) % length
What are the 3 types of lists?
Unordered Lists
Ordered Lists
Indexed Lists
Do indices need to start at zero for a list?
No it is an ADT not an array
What does the add(index, dataItem) do?
adds the data item at the specified index
What does the set(index, dataItem) do?
Sets dataitem at the specified index overwriting any data that was there
What does the remove(index) do?
Removes and returns the data item at the specified index
what does the indexOf(dataItem) do?
Returns the index of dataItem