Create
Learn
Share

This page helps you learn arrays vs vectors vs linked lists in java

rename
neostorm's version from 2018-06-24 20:56

Section

Question Answer
Static or dynamic:arrayStatic – fixed at runtime, cannot increase in size
Static or dynamic:vectorPseudo dynamic – creates a new data structure double the size of the original if memory limit is reached
Static or dynamic:linked listDynamic – consists of a series of nodes that can be added and deleted as needed
Data types that can be stored:arrayBoth primitive and object types
Data types that can be stored:vectorOnly object types but can use a wrapper class (Integer, Double, etc)
Data types that can be stored:linked listData portion can hold primitive or object types, but the link portion must hold a reference to the next node
Enumerated: arrayYes - an array is indexed and therefore you can jump to any location within the array based on an index value
Enumerated:vectorYes - a vector is indexed and therefore you can jump to any location within the vector based on an index value
Enumerated:linked listNo – each node is joined by a link and is not numbered. Typically only the front and end of the list is referenced for traversing purposes. To get to a node within the list you must “link jump” to the node
Contiguous:arrayYes – the memory is arranged in a logically adjacent fashion
Contiguous:vectorYes – the memory is arranged in a logically adjacent fashion
Contiguous:linked listNo – the memory is not arranged in a logically adjacent fashion
Random Access:arrayYes – see enumeration
Random Access:vectorYes – see enumeration
Random Access:linked listNo – see enumeration
Insertion/Deletion:arrayInsertion is possible if there is room, however if placed anywhere but the end of the array all other must be moved. Deletion is easy if takes place at the end, but difficult anywhere else
Insertion/Deletion:vectorInsertion is possible if there is room, however if placed anywhere but the end of the array all other must be moved. Deletion is easy if takes place at the end, but difficult anywhere else
Insertion/Deletion:linked listEasy to insert or delete anywhere within the list
Memory Location:arraySince arrays are objects, and objects are stored on the heap arrays, even when the elements contain primitive data types, are stored on the heap
Memory Location:vectorSince vector are objects and objects are stored on the heap vectors are stored on the heap
Memory Location:linked listSince nodes are objects and objects are stored on the heap linked lists are stored on the heap
memorize