Skip to content

feat: add binary insertion sort algorithm#71

Open
syedjafer wants to merge 5 commits into
TheAlgorithms:masterfrom
syedjafer:master
Open

feat: add binary insertion sort algorithm#71
syedjafer wants to merge 5 commits into
TheAlgorithms:masterfrom
syedjafer:master

Conversation

@syedjafer
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Member

@raklaptudirm raklaptudirm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a binary search implementation, so use that instead of making your own.

@syedjafer
Copy link
Copy Markdown
Author

Hi @raklaptudirm, the existing binary search will return -1 if we don't find the element. But my modified version find the position of the element that is to be inserted in the array. So I cant reuse it.

@raklaptudirm
Copy link
Copy Markdown
Member

Ah, makes sense.

@syedjafer
Copy link
Copy Markdown
Author

@appgurueu Can you please review this PR

@appgurueu
Copy link
Copy Markdown
Contributor

Hi @raklaptudirm, the existing binary search will return -1 if we don't find the element. But my modified version find the position of the element that is to be inserted in the array. So I cant reuse it.

You could consider updating the existing binary search.

@syedjafer
Copy link
Copy Markdown
Author

@appgurueu See the actuall Binary Search should return -1 if the key is not found. But in my function, I will be returning the insertion position of the key element.

@appgurueu
Copy link
Copy Markdown
Contributor

@appgurueu See the actuall Binary Search should return -1 if the key is not found.

No. Our current implementation behaves this way because it is lazily written. More advanced implementations return the insertion or occurrence index; it is then trivial to check whether the element was found (arr[idx] === element).

@syedjafer
Copy link
Copy Markdown
Author

@appgurueu yeah, correct.

How to proceed mate ? Do i need to close this PR and create a new one for Binary Search or Include the fix for binary search in this PR itself. ?

@appgurueu
Copy link
Copy Markdown
Contributor

@appgurueu yeah, correct.

How to proceed mate ? Do i need to close this PR and create a new one for Binary Search or Include the fix for binary search in this PR itself. ?

I'd be fine with including the extension/feature (not a fix, the current implementation is correct) in this PR.

@syedjafer
Copy link
Copy Markdown
Author

@appgurueu I have created a PR for Binary Search Improvement
#72

@zFl4wless
Copy link
Copy Markdown
Contributor

@appgurueu What about this PR? I think this can be closed

@appgurueu
Copy link
Copy Markdown
Contributor

@appgurueu What about this PR? I think this can be closed

It can be closed, yes, but why should it be closed? It would add something if it were merged. It's just that it currently depends on #72. The author should be able pick this up at any time.

@zFl4wless
Copy link
Copy Markdown
Contributor

An sorry, I understood this wrongly. I thought this PR was canceled

@github-actions github-actions Bot requested a review from Panquesito7 as a code owner March 19, 2023 12:06
Copy link
Copy Markdown
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The binary search is still duplicated locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants