Containers and Data Structures Flashcards

1
Q

A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following:

Interfaces:

Implementations:

A

Implementations: These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.

Implementations: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Queue:

A collection used to hold multiple elements prior to processing. Besides basic Collection operations, a Queue provides additional insertion, extraction, and inspection operations.

A

Queues are like lines. They follow FIFO (first in first out); when you pop, you pop from the front, but when you push, you push from the back.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Deque:

Deque stands for double ended queue, which is also a collection used to hold multiple elements prior to processing. A collection used to hold multiple elements prior to processing. Besides basic Collection operations, a Deque provides additional insertion, extraction, and inspection operations.

A

Deque’s can be used both as FIFO (first-in, first-out) and LIFO (last-in, first-out). In a deque all new elements can be inserted, retrieved and removed at both ends.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A Collection represents a group of objects known as its elements. The Collection interface is used to pass around collections of objects where maximum abstraction is desired. For example, by convention all general-purpose collection implementations have a constructor that takes a Collection argument. This constructor, known as a conversion constructor, initializes the new collection to contain all of the elements in the specified collection, whatever the given collection’s subinterface or implementation type. In other words, it allows you to convert the collection’s type.

A

Suppose, for example, that you have a Collection c, which may be a List, a Set, or another kind of Collection. This line of code creates a new ArrayList (an implementation of the List interface), initially containing all the elements in c:

List list = new ArrayList(c);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Collection Type, Number of Elements Inserted/Removed (10,000), and Time Taken

LinkedList 
Priority Queue
ArrayList
Vector
ArrayDeque
Stack
A

Queue pQueue = new PriorityQueue();

List arrayList = new ArrayList();

List vectorList = new Vector();

Deque arrayDeque = new ArrayDeque();

Stack stack = new Stack();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Each collection has their specific syntac for “push” and “pop”. What are they?

A

ArrayList

Priority Queue

Deque

ArrayDeque

Stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are certain collections faster and slower than others?

A

Due to the underlying data structures, this affects how elements are accessed, removed, and the entire collection is restructured

How well did you know this?
1
Not at all
2
3
4
5
Perfectly