Skip to content

#4382 Bug Fix #4384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged

Conversation

govardhanshah456
Copy link
Contributor

@govardhanshah456 govardhanshah456 commented Sep 20, 2023

Fixed The Bug for the Test Case mentioned in linked Issue as well as made code more readable.

Closes #4382.

Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

@govardhanshah456 thanks for working the issue #4382. I really like that you decided to rename the p1 and p2 member variables.

@govardhanshah456
Copy link
Contributor Author

Hey, i have made requested changes, please have a look into it.

Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

As a quick bug fix it looks really good. I suggest to add some tests (it is good to have a test case causing the original bug). You can use the commit suggestion button.

I know that this is out of scope for this PR, but I think it would be reasonable to make the MedianOfRunningArray a generic type, so one could compute a median of integers (and the result would be an integer), doubles (and the result would be a double) etc. @govardhanshah456 would you like to work on such an issue?

govardhanshah456 and others added 4 commits September 21, 2023 11:19
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…java

Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
…java

Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
@govardhanshah456
Copy link
Contributor Author

Hey, as you said its out of scope for this PR, what we can do instead is we can make new enhancement issue of making Median Generic and then work on it, that would appear more appropriate, and yes median would always be double for instance, (1,2) median would be (1+2)/2 which is double although input is int array.

Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

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

Awesome @govardhanshah456!

Closes #4382.

@vil02 vil02 enabled auto-merge (squash) September 21, 2023 06:03
@vil02 vil02 merged commit fbe348b into TheAlgorithms:master Sep 21, 2023
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.

[BUG] MedianOfRunningArray produces wrong output
2 participants