Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Odd-Even Merge Sort Base Case? #62

Closed
HaritzPuerto opened this issue Jun 6, 2019 · 2 comments
Closed

Odd-Even Merge Sort Base Case? #62

HaritzPuerto opened this issue Jun 6, 2019 · 2 comments

Comments

@HaritzPuerto
Copy link

HaritzPuerto commented Jun 6, 2019

Hello,

I think we need a base case in the code. I mean something like this:
`
procedure Merge(A,B)

if len(A) == len(B) == 1 then
     return <min(A[0], B[0]), max(A[0], B[0])>
else then
     (A_o, A_e) = ....

`

If we do not have this base case at the beginning, we would have an infinite recursion, wouldn't we? If A and B are composed of just one element, A_o = A and A_e = <> (Indexes start at 1). The same with B. So, Merge (A_o, B_o) would be the same as the original call Merge(A, B)

Am I right or am I missing something?

Thank you

@jeehoonkang
Copy link
Member

You're right. We indeed need a base case. Thank you for pointing out that!

@HaritzPuerto
Copy link
Author

Thank you!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants