2.3-DynamicArray

2.3-DynamicArray - CMPT 225 ADT List using Dynamic arrays A...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPT 225 ADT List using Dynamic arrays A dynamic data structure is one that changes size, as needed, as items are inserted or removed • The Java ArrayList class is implemented using a dynamic array There is usually no limit on the size of such structures, other than the size of main memory Dynamic arrays are arrays that grow (or shrink) as required • In fact a new array is created when the old array becomes full by creating a new array object, copying over the values from the old array and then assigning the new array to the existing array reference variable
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPT 225 Dynamic Array 6 1 7 8 top = 4 0 1 2 3 4 5
Background image of page 2
CMPT 225 Dynamic Array 6 1 7 8 top = 4 0 1 2 3 4 5 insert 5
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPT 225 Dynamic Array 6 1 7 8 5 top = 5 0 1 2 3 4 5
Background image of page 4
CMPT 225 Dynamic Array 6 1 7 8 5 top = 5 0 1 2 3 4 5 insert 2
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPT 225 Dynamic Array 6 1 7 8 5 2 top = 6 0 1 2 3 4 5 insert 3
Background image of page 6
CMPT 225 Dynamic Array 6 1 7 8 5 2 top = 6 0 1 2 3 4 5 insert 3 !The array is full and there is no room for a new item!
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 15

2.3-DynamicArray - CMPT 225 ADT List using Dynamic arrays A...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online