Skip to content

[BUG] MedianOfRunningArray produces wrong output #4382

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

Closed
vil02 opened this issue Sep 19, 2023 · 1 comment · Fixed by #4384
Closed

[BUG] MedianOfRunningArray produces wrong output #4382

vil02 opened this issue Sep 19, 2023 · 1 comment · Fixed by #4384
Labels

Comments

@vil02
Copy link
Member

vil02 commented Sep 19, 2023

Description

The implementation of MedianOfRunningArray has a bug.

Steps to reproduce

The code:

MedianOfRunningArray p = new MedianOfRunningArray();
p.insert(30);
p.insert(20);
p.insert(10);
System.out.print(p.median());

prints 10.

Excepted behavior

For such input, the output should be 20.

Screenshots

No response

Additional context

The code:

MedianOfRunningArray p = new MedianOfRunningArray();
p.insert(10);
p.insert(20);
p.insert(30);
System.out.print(p.median());

prints 20.

@vil02 vil02 added the bug label Sep 19, 2023
govardhanshah456 added a commit to govardhanshah456/Java that referenced this issue Sep 20, 2023
govardhanshah456 added a commit to govardhanshah456/Java that referenced this issue Sep 20, 2023
@vil02 vil02 mentioned this issue Sep 20, 2023
vil02 added a commit that referenced this issue Sep 21, 2023
* #4382 Bug Fix

* #4382 Bug Fix

* Made Requested Changes

* Made Requested Changes

* Made Requested Changes

* Made Requested Changes

* Made Requested Changes

* Made Requested Changes

* Made Requested Changes

* Update src/main/java/com/thealgorithms/misc/MedianOfRunningArray.java

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

* Update src/main/java/com/thealgorithms/misc/MedianOfRunningArray.java

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

* Update src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java

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

* Update src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java

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

---------

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

vil02 commented Sep 21, 2023

Closed by #4384.

@vil02 vil02 closed this as completed Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant