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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:50:10+00:00 2026-05-30T04:50:10+00:00

MergePoint (LinkList list1, LinkList list2){ p = list1.head; q = list2.head; while (p.next!=null &&

  • 0
MergePoint (LinkList list1, LinkList list2){
p = list1.head;
q = list2.head;
while (p.next!=null && q.next!=null){
    if (p.next == q.next){
        System.out.print(p.value + " is the Merging node");
        return;
    }
    p=p.next;
    q=q.next;
}

}

I’m trying to solve a problem to find out the merging node of 2 linked lists.
Before looking at other solutions, I decided to write my code and then compare to the other existing solutions.
The approach ive taken here is to find the common node that both the list pointers are pointing to.
Do you agree with this code or is there something im missing here?

  • 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-05-30T04:50:11+00:00Added an answer on May 30, 2026 at 4:50 am

    Your code will only work for the special class of cases where the merging node is in the same position in both the lists. I don’t think there’s an easy, sub-O(n^2) way to do this — in other words, you’ll need to compare every node of one list, with every next of second list, and vice versa.

    MergePoint (LinkList list1, LinkList list2) {
        p = list1.head;
        while (p != null) {
            q = list2.head;
            while (q != null) {
                if (p == q){
                        System.out.print(p.value + " is the Merging node");
                        return;
                }
                q = q.next;
            }        
            p = p.next;
        }    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to see the entire patch applied by a merge
I have two branches, the main branch(black) and a feature branch(yellow). As you can
var a = Observable.Range(0, 10); var b = Observable.Range(5, 10); var zip = a.Zip(b,
Overview: $ git pull ... time passes ... $ git checkout topic # remote
I'm working on an SSIS transform that joins a table with roughly 100k rows
Is it possible to set Git up so that I can use the three-way

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.