Challenge

Project 1 - Creation of user defined data type to implement the user interfaces for working with ‘Set’ (Mathematical Set theory) using Linked List

1. Creation of user defined data type to implement the user interfaces for working with ‘Set’

  • A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers.

A Data Item (we can store integer, strings, or any type of data).

Pointer (Or Reference) to the next node (connects one node to another) or An address of another node

UNION OF LIST : -

It is combination of two list where every element of lists are include except  repeated one.

In below program for union I create one more linked list which base address is pointed by result pointer.

First I insert all the element of list 1 to the result list and then add only that elements of list 2 which are not availabe to the result list.

This type of incertion is done using 

              int search(struct Node* head, int data) //head is pointer pointing to data type struct node
             {
                 struct Node* t = head;
                 while (t != NULL)
                  {
                      if (t->data == data)
                        {
                            return 1; //data is present in existing linked list.
                         }
                         t = t->link;
                  }
                    return 0;
             }

PROGRAM

Result :-

.

.........................................................................................................

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.