Placement 2025 Scholarship: Your Future Starts Here | 6 Guaranteed Job Interviews | Limited to 100 seats. Apply Now

00D 00H 00M 00S

Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Placements

Student Reviews


For Business


More

Academic Training

Informative Articles

Find Jobs

We are Hiring!


All Courses

Choose a category

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

All Courses

All Courses

logo

CHOOSE A CATEGORY

Mechanical

Electrical

Civil

Computer Science

Electronics

Offline Program

Top Job Leading Courses

Automotive

CFD

FEA

Design

MBD

Med Tech

Courses by Software

Design

Solver

Automation

Vehicle Dynamics

CFD Solver

Preprocessor

Courses by Semester

First Year

Second Year

Third Year

Fourth Year

Courses by Domain

Automotive

CFD

Design

FEA

Tool-focused Courses

Design

Solver

Automation

Preprocessor

CFD Solver

Vehicle Dynamics

Machine learning

Machine Learning and AI

POPULAR COURSES

coursePost Graduate Program in Hybrid Electric Vehicle Design and Analysis
coursePost Graduate Program in Computational Fluid Dynamics
coursePost Graduate Program in CAD
coursePost Graduate Program in CAE
coursePost Graduate Program in Manufacturing Design
coursePost Graduate Program in Computational Design and Pre-processing
coursePost Graduate Program in Complete Passenger Car Design & Product Development
Executive Programs
Workshops
For Business

Success Stories

Placements

Student Reviews

More

Projects

Blogs

Academic Training

Find Jobs

Informative Articles

We're Hiring!

phone+91 9342691281Log in
  1. Home/
  2. Kotesh Mogudala/
  3. 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

#include #include #include // Link list node struct Node {     int data;     struct Node* next; }; //function declaration void push(struct Node** head_ref, int new_data); int isPresent(struct Node* head, int data); // Function to get union of two linked lists head1 and head2 struct Node* getUnion(struct Node* head1, struct…

    • Kotesh Mogudala

      updated on 03 Feb 2023

    #include

    #include

    #include

    // Link list node

    struct Node {

        int data;

        struct Node* next;

    };

    //function declaration

    void push(struct Node** head_ref, int new_data);

    int isPresent(struct Node* head, int data);

    // Function to get union of two linked lists head1 and head2

    struct Node* getUnion(struct Node* head1, struct Node* head2)

    {

        struct Node* result = NULL;

        struct Node *t1 = head1, *t2 = head2;

        // Insert all elements of list1 to the result list

        while (t1 != NULL)

        {

            push(&result, t1->data);

            t1 = t1->next;

         }

        // Insert those elements of list2 which are not present in result list

        while (t2 != NULL)

        {

            if (!isPresent(result, t2->data))

            {

                push(&result, t2->data);

            }

            t2 = t2->next;

        }

        return result;

    }

    // Function to get intersection of two linked lists head1 and head2

    struct Node* getIntersection(struct Node* head1, struct Node* head2)

    {

        struct Node* result = NULL;

        struct Node* t1 = head1;

        // Traverse list1 and search each element of it in list2. If the element is present in list 2, then insert the element to result

        while (t1 != NULL)

        {

            if (isPresent(head2, t1->data))

            {

                push(&result, t1->data);

            }

            t1 = t1->next;

        }

        return result;

    }

    // A utility function to insert a node at the beginning of a linked list

    void push(struct Node** head_ref, int new_data)

    {

        // allocate node

        struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));

        // put in the data

        new_node->data = new_data;

        // link the old list off the new node

        new_node->next = (*head_ref);

        // move the head to point to the new node

        (*head_ref) = new_node;

    }

    // function to print a linked list

    void printList(struct Node* node)

    {

        while (node != NULL)

        {

            printf("%d ", node->data);

            node = node->next;

        }

    }

    // function that returns true if data is present in linked list else return false

    int isPresent(struct Node* head, int data)

    {

        struct Node* t = head;

        while (t != NULL)

        {

            if (t->data == data)

            {

                return 1;

            }

            t = t->next;

        }

        return 0;

    }

    // Driver program to test above function

    int main()

    {

        int n,m,temp;

        printf("enter the value of number of value in link list(both):-");

        fflush(stdout);

        scanf("%d %d", &n, &m);

        // Starth structure pointer with the empty list

        struct Node* head1 = NULL;

        struct Node* head2 = NULL;

        struct Node* intersecn = NULL;

        struct Node* unin = NULL;

        //for loop for link list1

        for(int i=0;i

        {

            printf("Enter the value in link list1 %d:-",i);

            fflush(stdout);

            scanf("%d", &temp);

            push(&head1, temp);

        }

       //for loop for link list2

       for(int i=0;i

       {

           printf("Enter the value in link list2 %d:-",i);

            fflush(stdout);

            scanf("%d", &temp);

            push(&head2, temp);

     

       }

       //call the function of intersection

        intersecn = getIntersection(head1, head2);

        //call the function of union

        unin = getUnion(head1, head2);

        printf("\n First list is ");

        //function calling with structure pointer as argument

        printList(head1);

        printf("\n Second list is ");

        printList(head2);

        printf("\n Intersection list is ");

        printList(intersecn);

        printf("\n Union list is ");

        printList(unin);

        return 0;

    }

    Leave a comment

    Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.

    Please  login to add a comment

    Other comments...

    No comments yet!
    Be the first to add a comment

    Read more Projects by Kotesh Mogudala (12)

    Project 2

    Objective:

      a)       Max. heat generation of the battery pack is  Heat generation (Wh) = *R*t.I = 0.896 AmpsR = 2m Ωt = 120 secs = 0.03333 hoursHeat generation (W sec) = *0.002*120                                                =…

    calendar

    24 May 2024 01:04 PM IST

      Read more

      Project 1

      Objective:

      1.     Design a battery pack for a car roughly 150 Kw with 120 V. Use 3500 mAh 3.6V nominal NMC chemistry cell.a.     Design the battery pack configuration. b.     Draw the BMS topology for this battery pack.a)      Given, we have…

      calendar

      24 May 2024 12:40 PM IST

        Read more

        Project 1 - Controlling a DC motor using PWM and monitoring its Running status

        Objective:

        Live Batch (Preeti Mallikarjun):  

        calendar

        01 Aug 2023 12:31 PM IST

          Read more

          Project 3

          Objective:

          Live Batch ( Preeti Mallikarjun ):  

          calendar

          22 May 2023 11:26 AM IST

            Read more

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

            Related Courses

            coursecard

            Design loads considered on bridges

            Recently launched

            10 Hours of Content

            coursecard

            Design of Steel Superstructure in Bridges

            Recently launched

            16 Hours of Content

            coursecard

            Design for Manufacturability (DFM)

            Recently launched

            11 Hours of Content

            coursecard

            CATIA for Medical Product Design

            Recently launched

            5 Hours of Content

            coursecardcoursetype

            Accelerated Career Program in Embedded Systems (On-Campus) Courseware Partner: IT-ITes SSC nasscom

            Recently launched

            0 Hours of Content

            Schedule a counselling session

            Please enter your name
            Please enter a valid email
            Please enter a valid number

            logo

            Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.

            https://d27yxarlh48w6q.cloudfront.net/web/v1/images/facebook.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/insta.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/twitter.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/youtube.svghttps://d27yxarlh48w6q.cloudfront.net/web/v1/images/linkedin.svg

            Our Company

            News & EventsBlogCareersGrievance RedressalSkill-Lync ReviewsTermsPrivacy PolicyBecome an Affiliate
            map
            EpowerX Learning Technologies Pvt Ltd.
            4th Floor, BLOCK-B, Velachery - Tambaram Main Rd, Ram Nagar South, Madipakkam, Chennai, Tamil Nadu 600042.
            mail
            info@skill-lync.com
            mail
            ITgrievance@skill-lync.com

            Top Individual Courses

            Computational Combustion Using Python and CanteraIntroduction to Physical Modeling using SimscapeIntroduction to Structural Analysis using ANSYS WorkbenchIntroduction to Structural Analysis using ANSYS Workbench

            Top PG Programs

            Post Graduate Program in Hybrid Electric Vehicle Design and AnalysisPost Graduate Program in Computational Fluid DynamicsPost Graduate Program in CADPost Graduate Program in Electric Vehicle Design & Development

            Skill-Lync Plus

            Executive Program in Electric Vehicle Embedded SoftwareExecutive Program in Electric Vehicle DesignExecutive Program in Cybersecurity

            Trending Blogs

            Heat Transfer Principles in Energy-Efficient Refrigerators and Air Conditioners Advanced Modeling and Result Visualization in Simscape Exploring Simulink and Library Browser in Simscape Advanced Simulink Tools and Libraries in SimscapeExploring Simulink Basics in Simscape

            © 2025 Skill-Lync Inc. All Rights Reserved.

                        Do You Want To Showcase Your Technical Skills?
                        Sign-Up for our projects.