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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:48:24+00:00 2026-05-15T03:48:24+00:00

here is pseudo code on algorithm to find median of two array T WO

  • 0

here is pseudo code on algorithm to find median of two array

T WO -A RRAY-M EDIAN (X, Y )
n ← length[X]                  £ n also equals length[Y ]
median ← F IND -M EDIAN (X, Y, n, 1, n)
if median = NOT- FOUND
   then median ← F IND -M EDIAN (Y, X, n, 1, n)
return median
F IND -M EDIAN ( A, B, n, low, high)
if low > high
   then return NOT- FOUND
   else k ← (low + high)/2
        if k = n and A[n] ≤ B[1]
           then return A[n]
        elseif k < n and B[n − k] ≤ A[k] ≤ B[n − k + 1]
           then return A[k]
        elseif A[k] > B[n − k + 1]
           then return F IND -M EDIAN ( A, B, n, low, k − 1)
        else return F IND -M EDIAN ( A, B, n, k + 1, high)

it is from introduction of algorithms MIT

and here is my code please if something is wrong in my code tell me

    public class findmedian{
public static  int   find(int []x,int []y){
int median;
int n=x.length;
   median=Median( x, y, n,0, n);
  if ( median<-100000){
    Median(y,x, n,1, n);

}

 return median;  


 }


public static void main(String[]args){
 int x[]=new int[]{3,5,7,8,5,9,10};
 int y[]=new int[]{12,4,8,9,6,7,10};
find(x,y);


}

public static  int  Median(int []a,int []b,int n,int low,int high)
{


   if ( low>high)
 return -1  ;
  int k=(low+high)/2;
  if (k==n  && a[n]<=b[1])
   return a[n];
 else   if ( k<n && b[n-k]<=a[k] && b[n-k]<=b[n-k+1])
 return a[k];
   else if ( a[k]> b[n-k-1])
 return   Median( a,b,n,low,k-1);





 return  Median(a,b,n,k+1,high);





}


}

after compile it does not return anything please help

  • 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-15T03:48:25+00:00Added an answer on May 15, 2026 at 3:48 am
     if ( low>high)
     return;
    

    Is this the error? You need to return something. (The return type is int)

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

Sidebar

Related Questions

Here is the pseudo-code for my inline query in my code: select columnOne from
Here's what I'm trying to do -- this is pseudo code and doesn't work.
Here is the psuedo code for what I want to do IF NOT ISDIRTY
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
in an Introduction to Algorithm 2nd edition, I found insertion sort pseudo code INSERTION-SORT(A)
I've written a QuickSort algorithm based off pseudo-code that I had been given. I've
I'm trying to implement Dijkstra's algorithm in Java (self-study). I use the pseudo-code provided
I am using pseudo-code here, but this is in JavaScript. With the most efficient
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works

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.