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 8792543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:59:35+00:00 2026-06-13T22:59:35+00:00

I have an integer linked list of which both first half and second half

  • 0

I have an integer linked list of which both first half and second half are sorted independently.Now i need to merge two parts to create one single sorted linked list.

Sample input:

Input List 1: 1->2->3->4->5->1->2

Output : 1->1->2->2->3->4->5

Input List 2: 1->5->7->9->11->2->4->6

Output 2: 1->2->4->5->6->7->9->11

Expected output:

1,2,3…..

  • 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-13T22:59:35+00:00Added an answer on June 13, 2026 at 10:59 pm

    This is merge sort.

    I will maintain two pointers:

    ptr1 points to the first half’s first element

    and ptr2 points to the second half’s first element.

    you will need an extra array to store the final list, of course you can choose not to use this extra array, but that discussion is far away from the topic.

    1, Compare *ptr1 and *ptr2, if *ptr1‘s value is smaller than *ptr2, then copy that value(i.e. *ptr1) to the final array, and let ptr1 move forward.

    if ptr2‘s value is the smaller one, just copy *ptr2 and let ptr2 move forward

    2, Stop when the pointer points after the last element, say if you have 5 elements in the first half a[0] a[1] a[2] a[3] a[4], then you should stop when the pointer points to
    a[5]

    3, If the first half is empty, then copy the rest of the second half, vice versa.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a simple linked list class and I would now like to
I have two integer values, x and total. I am trying to find the
I need to create an SQLAlchemy version of a linked list. It's actually more
I have this HashMap: HashMap<String, Integer> m which basically stores any word (String) and
So I want to copy a whole linked list classes, I have trouble figuring
how can I create a linked list in actionScript 3.0? I have a project
I want to store data at run time, I can have a linked list
I have the following struct for a linked list: struct Node { int type;
Gurus, I have difficulty to pass an arraylist of doubly-linked list as a parameter.
Let's say I have a class which, internally, stores a List of data: import

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.