Get ahead with a $300 test prep scholarship
| Enter to win by Tuesday 9/24
Terms in this set (37)
A ___ data structure has a fixed size.
An example of static data structure?
An array. Once size is set it stays the same
A ______ data structure grows and shrinks at execution time as required by its contents
Example of dynamic data structure.
What is a vector?
what is a list?
interface with two implementations
What is a Vector useful for?
useful for multi-threaded programs where thread-safe(synchronization) operations are required
ArrayList vs LinkedList
ArrayList is indexed the normal way and LinkedLists have pointers after each data. So 1st data links to 2nd data. 2nd data links to 3rd data.
Recall that an ____ ____ is a variable that stores the address of an object
A reference is also called a
A method called _____ could be defined to place a node anywhere in the list, for example to keep it sorted
A method called _____ could be defined to remove a node from the list
Pros for ArrayList
Constant time (i.e. does not depend on the size of the list) Fast for random access
Cons for ArrayList
slow for adding and deleting at the start and middle of the list because all the later elements have to copied forward or backward.
Pros for LinkedList
Constant time. For applications that add to beginning of the list or iterate over the list deleting elements from its interior, consider using LinkedList
Cons for linked List
Random access requires linear time. So you must start from beginning or end and go one step at a time to find certain index
Constant time is fast and linear time is slow?
are fast for inserts and deletes
ArrayLists use more memory than LinkedLists?
List abstract data types dealing with lists?
Queue and Stack
is an organized collection of information and a set of operations used to manage that information
Abstract data type (ADT)
defines the interface to the ADT
The set of operations
Classic linear data structures include
queues and stacks
Classic nonlinear data structures include
trees, binary trees, and graphs
Uses FIFO. is similar to a list but adds items only to the rear of the list and removes them only from the front
add an item to the rear of the queue
remove an item from the front of the queue
returns true if the queue is empty
By storing generic Object references, any object can be stored in the queue?
A built-in queue is provided in the _______ class
A stack is linear, like a list or a queue.
Items are added and removed from only one end of a stack
It is therefore LIFO: Last-In, First-Out
Analogy: a stack of plates in a cupboard
For stack what do push and pop do
push puts item at end. Pop takes out item at end
push - add an item to the top of the stack
pop - remove an item from the top of the stack
retrieves the top item without removing it
returns true if the stack is empty
Set: a collection of items with no duplicates
List: a collection of items which may have duplicates
Queue: a collection for holding and processing items in FIFO order
Deque: a double-ended Queue
Map: a group of items that can be referenced by a key value
Stack: a collection for holding and processing items in LIFO order
is implied in the class names such as ArrayList and LinkedList
The underlying implementation