Presentation is loading. Please wait.

Presentation is loading. Please wait.

Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.

Similar presentations


Presentation on theme: "Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision."— Presentation transcript:

1 Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision that duplicate values are not allowed. Applications typically use Set collections for operations set union, set intersection, and set difference.

2 Student Question Given the following sets: Find the following sets:
A = {3, 4, 8, 2} B = {16, 4, 12, 8} C = {2, 3, 4, 5, 6} Find the following sets: (A  B)  C A – B – C (A  C)  (B  C)

3 Map Collection A Map is a collection of key-value pairs. The key uniquely identifies the element while the value field typically has associated data. Access to an element requires only the key and returns the value component. For this reason, a Map is referred to as an associative array.

4 Stack Collection A Stack is a collection with a single reference point called the top of the stack. An element is added at the top of the stack (push operation) and removed from the top of the stack (pop operation). Elements come off a stack in the reverse order of their insertion and so a stack has last-in-first-out (LIFO) ordering.

5 Queue Collection A Queue is a collection that allows access only at the front and the back. Items enter at the back (push or enqueue operation) and exit from the front of the queue (pop or dequeue operation). Elements come off a queue in the same order of their insertion and so a queue has first-in-first-out (FIFO) ordering.

6 Priority Queue A Priority Queue is a collection that has restricted access operations, like a stack and a queue. An element can enter the queue in any order. Once in the collection, a delete operation removes the maximum (minimum) value, depending on the specified type of priority.

7 Student Question How can you use a linked list to implement a priority queue? What is the complexity of the insert and delete operations? How can you use an ordered list to implement a priority queue? What is the complexity of the insert and delete operations?

8 Graph Collection A Graph is a set of vertices connected by links, called edges. Depending on the application, an edge may or may not have a direction and/or a weight. A digraph has directed edges; a weighted graph has edges with weights.

9 Student Question We learned about binary search trees in CS Are trees an example of a collection? How are trees related to graphs?

10 Java Collection Framework
The Java Collection Framework is a group of collections defined using interfaces abstract classes, and inheritance.


Download ppt "Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision."

Similar presentations


Ads by Google