Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List
Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List.
Ans -
Aim - Create a .c program file for Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List.
Procedure -
1) Create a .c program file
2) Write a program and run it
3) Get the output on console.
In this project, interfaces for mathematical Set Theory are implemented using C programming language. User can give the input like two list of data and this program will give the output as the union and intersection of these two lists.
- > Linked List
Linked List can be defined as collection of objects called nodes that are randomly stored in the memory.A node contains two fields i.e. data stored at that particular address and the pointer which contains the address of the next node in the memory.The last node of the list contains pointer to the null.
- > Uses of Linked List
The list is not required to be contiguously present in the memory. The node can reside any where in the memory and linked together to make a list. This achieves optimized utilization of space.list size is limited to the memory size and doesn't need to be declared in advance.Empty node can not be present in the linked list.We can store values of primitive types or objects in the singly linked list.
- > Intersection of data of two list.
Intersection of two list means we need to take all those elements which are common to both of the initial lists and store them into another list.
The following are simple algorithms to get union and intersection lists respectively.
1. Intersection (list1, list2):
Initialize the result list as NULL. Traverse list1 and look for every element in list2, if the element is present in list2, then add the element to the result.
2. Union (list1, list2):
Initialize the result list as NULL. Traverse list1 and add all of its elements to the result.
Traverse list2. If an element of list2 is already present in the result then do not insert it to the result, otherwise insert.