Perfection (in design) is achieved not when there is nothing more to add, but rather when there is nothing more to take away Antoine de Saint-Exupery

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.



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”,”]



No comments available!

Please login to add comments.