Sets and Dictionary: Operations (Methods) On Dictionaries
Sets and Dictionary: Operations (Methods) On Dictionaries
Sets are groups of items, unordered with duplicates removed. The keys of a dictionary form a set,
but each key has an associated value; these values could be duplicated within a dictionary.
A dictionary is a general-purpose data structure for storing a group of objects . A dictionary is an
ordered or unordered list of key-element pairs, where keys are used to locate elements in the list.
Example: consider a data structure that stores bank accounts; it can be viewed as a dictionary,
where account numbers serve as keys for identification of account objects.
A dictionary is also called a hash, a map, a hashmap in different programming languages. They
are all the same thing: a key-value store.. Keys in a dictionary must be unique.
Implementations of an ordered dictionary are binary search trees and AVL trees which are
binary search trees of a special type. Implement an unordered dictionary is by a hash table
Sets and dictionaries are ideal data structures to be used when your data has
not in order, but does have a unique object that can be used to reference it. This reference object
is called the “key,” while the data is the “value.” Dictionaries and sets are almost identical,
except that sets do not actually contain values: a set is simply a collection of unique keys. As the
name implies, sets are very useful for doing set operations.
Dictionaries are ordered or unordered lists. The easiest way to implement a list is by means of an
ordered or unordered sequence.
InsertItem(5,A) {(5,A)}
InsertItem(5,A) {(5,A)}
A disjoint-set data structure (also called a union–find data structure or merge–find set) is a
data structure that keeps track of a set of elements partitioned into a number of disjoint (non-
overlapping) subsets. A union-find algorithm is an algorithm that performs three useful
operations on such a data structure:
2. The Find-Set operation determine which subset a particular element is in. This can be
used for determining if two elements are in the same subset.
Union-Find Algorithm can be used to check whether an undirected graph contains cycle or not.