Challenge

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

// creating two list of data using linked list method.

               #include

               #include

               typedef struct nide

                 {

               int data;

                struct node*next;

                 }

                nide;

                node*create linkedlist (int n);

                void display list (node*head);

                 int main()

               {

               int n=0;

               node*HEAD=NULL;

                printf("\n how many nodes");

                scanf("%d",&n);

                HEAD=create linked list(n);

                 displaylist(HEAD);

                return0;

               }

node*create linked list (int h)

{

int i=0;

node*head =null;

node*temp=null;

node*p      = null;

for(i=0;i

{

//let us create individual isolated node 

temp=(node*) malloc (size of (node));

printf("\n enter the data for node number:,i+1);

temp-> next =null;

if(head ==null)

{

head=temp;

}

else

{

p=head;

while(p->next!=null)

p=p->next=temp;

}

}

return head;

}

void dispaylist (node*head)

{

while (p>next!=null)

{

printf("\t%d->",p->data);

p=p->next;

}

teturn0;

}

                      // insert node

#include

#include

public void insert()

{

linkedlist next;

int count =1,pos;

current = head;

scanner s= new scanner (system in)

s.o.p("enter which position uwant to insert");

pos=s.next int();

s.o.p("enter element");

int ele=s.nextint();

temp=new linkedlist();

temp data=ele;

it (pos==1)

{

temp.next =head;

head=temp;

}

else

{

{

while(cout

{

current =current.next;

count ++;

}

next=current .next;

current.next=temp;

temp.next=next;

}

s.o.p("after inserttion");

display();

linked count ++;

}

return 0;

}

                                           // intersection of data of two lost

#include

#include

          void display (node*head)

         {

            node*temp=head;

            while (temp!=null)

            {

            cout<data<< "->";

            temp =temp-> next;

              }

           cout<<"null"<

              }

             int lenght (node*head)

              {

               int l=0;

             node*temp=head;

              while (temp!=null)

             temp=temp->next;

               l++

               }

                return L;

                 }

              int intersection (node*&head1,node*&head2)

 {

                   int l1=length (head1);

                 int l2=length(head2);

                int d=0;

node*ptr1;

node*ptr2;

if(l1>l2)

{

d=l1=l2;

ptr1=head1;

ptr2+=head2;

}

else

{

d=l2-l1;

ptr1=head2;

ptr2=head 1;

}

while(d)

{

ptr1=ptr 1->next;

if (ptr1==null)

{

return -1;

}

d--;

}

while(ptr1!=null&& ptr2!=null)

{

if (ptr1==ptr2)

{

return ptr1->data;

}

ptr1=ptr 1->next;

ptr2=ptr2->next;

}

return-1;

}

int main()

{

node* head 2=null;

insert attail(head1,1);

insert attail(head1,2);

insert attail(head1,3);

insert attail(head1,4);

insert attail (head 1,5);

insert at tail (head 1,6);

insert attail(head 2,8);

insert attail(head 2, 10);

intersect (head1,head2,3);

display(head1);

display(head2);

cout<

return 0;

}

//union

#include

#include

union un

{

int a;

int b;

int c;

};

void main()

{

union main()

{

union un v;

clrscr();

printf("\n\n the size of union variable =%d",size of (v));

printf("\n\n the size of union =%d", size of (union un));

v.a=10;

v.b=3.14;

v.c='A';

printf("\n\n int value =%d", v.a);

printf("\n\n float value+%f",v.b);

printf("\n\n character value=%c", v.c);

}

return 0;

}

//union & intersection

#include

void main()

{

int a[100],b[100];

int n1,n2,i,j,c,s;

printf("enter first arry elements number\n\t");

scanf("%d",&n1);

for (i=0;i

{

printf("enter %d element of forst array",i+1);

scanf("%d",&a[i])

}

printf("enter second array element number \n\t");

scanf("%d",&n2);

for (i=0;i

{

printf("enter %d element of second array ",i+1);

scanf(i=0;i

{

printf("enter %d element of second array ",i+1);

scanf("%d",&c);

if(c==1)

{

printf("intersection between ka and b\n");

for(i=0;i

{

for(j=0;j

{

if(a[i]==b[j])

printf("%d",2[i]);

}

}

else if (C==2)

{

printf("union between a and b");

s=n1+n2;

for (i=n1,j=0;i

{

a[i]=b[j];

}

return 0;

}

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.