Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:38:51+00:00 2026-06-01T10:38:51+00:00

i got 3 linked list and union function a b and result are lists

  • 0

i got 3 linked list and union function

a b and result are lists i want to fill result list with elements but it is always empty.

main is result.UnionSets(a,b) function is

void UnionSets(linkedlist & l1, linkedlist & l2)
{       
    node<type> *temp=   l1.tail;
    if(temp!=NULL)
    {
        while(temp->next!=tail)
        {
            AddNode(temp->data);
            temp=temp->next;            
        }
    }
    temp=l2.tail;
    if(temp!=NULL)
    {
        while(temp->next!=tail)
        {
            AddNode(temp->data);
            temp=temp->next;

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:38:53+00:00Added an answer on June 1, 2026 at 10:38 am

    I need to assume some things about your linked list implementation. If my assumptions are wrong, then my answer is wrong, too.

    1. You are initializing your temp pointers to the tail element of their linked lists. The typical nomenclature is to start at head and work towards tail. Also, it is typical that the in final node has NULL as its next pointer.

    2. You are comparing nodes of one linked list to nodes on a different linked list. Are the linked lists actually cross-linked? Or are they actually independent of each other?

    Taking those two points into account, try this:

    void UnionSets(linkedlist & l1, linkedlist & l2)
    {       
        node<type> *temp=   l1.head;
        while(temp!=NULL)
        {
                AddNode(temp->data);
                temp=temp->next;            
        }
        temp=l2.head;
        while(temp!=NULL)
        {
                AddNode(temp->data);
                temp=temp->next;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the code from wikipedia for linked list ( http://en.wikipedia.org/wiki/Linked_list ). But it
I'm trying to create a linked list, I've got it working, but I'm still
I've got a structure which holds names and ages. I've made a linked-list of
I got some problem with the linked list I've written. I dunno if it's
I am trying to implement a linked list using following code, I got segment
I'm writing a function in C that takes in a linked list and a
I've got two collections, each containing about 40,000 items. The elements in list 2
I'm implementing a singly-linked list in C and got stuck with the remove node
I got a problem here, implementing a Sorted Doubly Linked List of first and
i have a double linked list with many list elements. so i can use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.