Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning. Rich Cook

Set implementation

Language Java | Level Intermediate | Category Data structure | September 9, 2015 9:33 am


Data structure Description

The set is a data structure that can store values without any order and do not contain duplicate elements. The set is a computer implementation of a finite set. It contains finite natural number of elements. The subset is a set build from master set and has few elements. Example, Set S={1, 2, 3, 4, 5}, Subset = { {1, 2, 3}, {2, 3}, {1}}. The set can be implemented using linked lists, vectors and hash tables. It can be static and dynamic. Static set cannot change the elements after constructing the elements. The dynamic set can add or remove the elements after construction. The static set contains build and ternate the elements from the set. But the dynamic set support add, remove operations too.

Multiset or bag is the generalization of the set which support multiple duplicate values. Multisets can naturally be implemented using the hash table or trees.

Write a program to implement the set operations.


Output

   					 

Itmes in the set: [One”,two”,Three”,four”,five”,”]
Set size: 5
Does Set contains 'One' : true
Itmes in the set: [One”,two”,Three”,four”,five”,ten”,null”,null”,null”,null”,”]


				    

Comments


No comments available!

Please login to add comments.