Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- Set data structure 2 by Tech_MX 3665 views
- Sets and disjoint sets union123 by Ankita Goyal 2499 views
- 18. Dictionaries, Hash Tables and Sets by Intro C# Book 79035 views
- Set Operations - Union Find and Blo... by Amrinder Arora 2150 views
- 07. disjoint set by Onkar Nath Sharma 822 views
- Disjoint sets by Core Condor 1168 views

No Downloads

Total views

11,327

On SlideShare

0

From Embeds

0

Number of Embeds

8

Shares

0

Downloads

293

Comments

0

Likes

8

No embeds

No notes for slide

- 1. Introduction• A set is a collection of objects need not to be in any particular order.• It is just applying the mathematical concept in computer.• Rules: Elements should not be repeated. Each element should have a reason to be in the set.
- 2. Set example : Assume we are going to store Indian cricketers in a set. * The names should not be repeated, as well the name who is not in a team can’t be inserted. * This is the restriction we found in a set.
- 3. NULL SET(EMPTY SET)• The set with no element is called null set or empty set.For example:A={x | x is a prime number, where 24<x<29} This set can’t contain a element. We don’t have any prime number within the limit 24 and 29.A={ }
- 4. Basic Operationso set union(set1,set2)o set intersection(set1,set2)o set difference(set1,set2)o int subset(set1,set2)
- 5. UNION• Combine two or more sets(here two sets), without violating the rules for set.
- 6. INTERSECTION• Gathering common elements in both the sets together as a single set.
- 7. DIFFERENCE• Forming a set with elements which are in first set and not in second set.• A-B= {x| for all x belongs to A but not in B}
- 8. SUBSET• int subset(set1 , set2)• Returns 1 if the set1 is the subset of the set2., otherwise 0 if not.• Here, A c B(A contained in B)
- 9. TypesImmutable Mutable(Static) (Dynamic)
- 10. Operations on Mutable• void* create(n)• add(set , element);• delete(set , element);• int capacity(set);
- 11. CREATE• void* create(int n) – It simply create the set that can be used to store ‘n’ elements and return the starting address of the set in memory. int *set=create(30);
- 12. ADD• add(set set_name , type value) – This function add one element into the set specified in the function argument. – The set_name argument is to mention the set which is going to be updated. – value argument is the value to be inserted into the set that passed to the function.
- 13. DELETE• delete (set set_name , type value) – This function delete one element from the set specified in the function argument. – The set_name argument is to mention the set which is going to be updated. – value argument is the value to be deleted from the set that passed to the function.
- 14. CAPACITY• int capacity(set set_name) – This function is used to find the maximum number of elements can be stored into the set that passed to the function. – Find the count and return the integer value.
- 15. Operations on Immutable• int elementof(x , S)• int empty(S)• int size(S)• void* build(x1 , x2 , … , xn)
- 16. ELEMENTOF• int elementof(type x , set set_name) – This function check for the element ‘x’ in the passed set. – Returns the value whether 0 or 1. – If the X is there in the set, return 1 otherwise 0.
- 17. EMPTY• int empty(set set_name) – This function checks for the emptiness of the set that passed to the function. – If the set is empty, return 1 else 0.
- 18. SIZE• int size(set set_name) – Returns the number of elements in set.
- 19. BUILD• void* build(set_elements) – This function create the set with the given elements and return the address of the first element. – Return the void* , we can assign that pointer to the type* which type we declared the set.
- 20. • intersection()Here, function for set with the type int.int* intersection(int set1[100],int set2[100]){int inter[100],k=0;for(i=0;i<size(set1);i++) for(j=0;j<size(set2);j++) if(set1[i]==set2[j]) { inter[k]=set[i]; k++; }return inter;}
- 21. • union()int* union(int set1[100],int set2[100]){ int uin[100]; for(i=0;i<size(set1);i++) { uin[i]=set1[i]; } for(j=0;j<size(set2);j++) { if(!find(uin,set2[j])) { uin[i]=set2[j]; i++; } }return uin;}
- 22. • elementof()int elementof(int set[100],int x){ for(i=0;i<size(set1);i++) { if(set[i]==x) return 1; }return 0;}
- 23. Dynamic memory allocation Header file for this is <alloc.h>void* malloc(int size_of_block)void* calloc(int number_of_blocks, int size_of_each_block)void free(void* ptr)realloc(void* ptr, int size)
- 24. HASH FUNCTION• Before entering into an application of set data structure, we need to discuss about hash function.• Hash function is a function that generate an integer number with a particular logic.• This function is like a one way entry. We can’t reverse this function. But by doing the process with the same number we may get an answer.
- 25. • Sometimes the same value may be generated for the different values. In that case, we need to check for the data in that location.• In some cases, same values will generate the different output. Both are possible.• We have to select a hash function which is not repeating the values generated.
- 26. Spelling checker• Here, is a simple example for spelling checker.• This concept applied by using the hash table data structure.• The two files are provided to us for process. One is “dictionary file”, which is the collection of meaningful words, and another one is “input file”, that contains the word to be validated for spell.
- 27. • Initially the words from the dictionary file and also from input file be inserted into the hash tables separately.• And the intersection operation will be done between the two hash tables.• If the set with one element is the result of the intersection, then the word is in dictionary. Spell is perfect. If, null set returned form the intersection, then the spell is wrong.
- 28. The set data structure is indirectlyimplemented using such as trees, tries, hashtables, arrays, by restricting ourself whilestoring data. This is widely used data structurewhen we need no repetition as well acollection.

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment