Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List
Aim of Project:
Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List
Description of Theory:
Linked list
The components of a linked list, a linear data structure, are linked together using pointers rather than being stored in a single continuous location. Each node in a connected list of nodes holds data as well as the address of the node after it.

Node structure: A node in a linked list normally has two parts:
Information: It contains the node's actual value or data.
Next Pointer: It keeps a reference to the next node in the chain's memory address.
Head and Tail: The head node, which points to the list's first node, is used to access the linked list. The list ends when the last node in the list points to NULL or nullptr. The tail node is this node's official name.
There are mainly three types of linked lists:
- Single-linked list
- Double linked list
- Circular linked list
user define Data type:
"The user-defined data types in C" is a set of data whose values all have predetermined meanings. A preset value that aids in declaring, accessing, and storing data is known as a data type in C. The primary or built-in data types in C can be used to produce the user-defined data types.
Integer, char, float, and other primitive data types are known to exist in C. The foundational elements for user-defined data types in C are these primitive data types. The necessity, definition, and numerous user-defined data types in C will all be covered in this article.
there are four types of user define data types.
- Structures
- Union
- Typedef
- Enum
Mathematical Theory of Set:
In the area of mathematical logic known as set theory, we study sets and their characteristics. A set is a grouping or collection of objects. These things are frequently referred to as elements or set members.
Types of Sets
The sets are further categorised into different types, based on elements or types of elements. These different types of sets in basic set theory are:
- Finite set: The number of elements is finite
- Infinite set: The number of elements are infinite
- Empty set: there is no element present in set
- Singleton set: one only element present in set
- Equal set: if same elements in Two sets are equal
- Equivalent set: Two sets are equivalent if they have same number of elements
- Power set: A set of every possible subset.
- Universal set: Any set that contains all the sets under consideration.
- Subset: When all the elements of set A belong to set B, then A is subset of B
In this project we have to create the two sorted linked list. first we have declared the user define datatype struct. For that list we develop the c logic to take as number of node in list and data/elements in list as input. In this we check that the list is empty or nor. If it is empty then program will display the message. Same way we have take the input for second list. We have developed the logic for create the new node and insert this node into the list node. for that we check the condition that if list does not have any then head will the new node and the value of it will be same for head. If the list is not contain null value then it check the condition and insert the in list. Next in the C program we have to perform the mathematical set operation of union and intersection. Here we consider one sorted list as list1 (L1) and second sorted list as list1 (L2). In the case of union this operation compare two sets of list and gives the output list in which unique elements are present. In intersection operation of the mathematical set. In this operation it compare the two set and give the output list as common elements of two lists. The c logic for this mathematical set operation is developed in the c program.
Step for login implementation:
Step 1 - Initialize the lists as NULL
Step 2 - Take user input for number of nodes of both list
and create new nodes and assign user defined values to them
Step 3 - Display the lists
Step 4 - Perform union and display the union list
Step 5 - Perform intersection and display the list
C Program for the project:
Outputs:
1)
Enter number of nodes in list 1: 5
Enter 5 elements of list 1: 1 2 3 4 5
Enter number of nodes in list 2: 5
Enter 5 elements of list 2: 3 4 5 8 9
List 1 is 1 2 3 4 5
List 2 is 3 4 5 8 9
Union of both list is 1 2 3 4 5 8 9
Intersection of both list is 3 4 5
2)
Enter number of nodes in list 1: 6
Enter 6 elements of list 1: 10 12 15 75 86 45
Enter number of nodes in list 2: 6
Enter 6 elements of list 2: 15 45 42 17 63 91
List 1 is 10 12 15 45 75 86
List 2 is 15 17 42 45 63 91
Union of both list is 10 12 15 17 42 45 63 75 86 91
Intersection of both list is 15 45
Screen short of program and output:


Result:
In this way, we have inserted the new node into the sorted linked list which takes as input from the user and perform the mathematical union and insertion operation.