Skip to content
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

Added Binary Heaps #42

Closed
wants to merge 0 commits into from
Closed

Added Binary Heaps #42

wants to merge 0 commits into from

Conversation

23umesh
Copy link

@23umesh 23umesh commented Dec 10, 2019

References to other Issues or PRs or Relevant literature

Brief description of what is fixed or changed

Added binaryHeap to pydatastructs

Other comments

Implemented using list.

@codecov
Copy link

codecov bot commented Dec 10, 2019

Codecov Report

Merging #42 into master will decrease coverage by 0.166%.
The diff coverage is 96.598%.

@@              Coverage Diff              @@
##            master       #42       +/-   ##
=============================================
- Coverage   97.895%   97.729%   -0.167%     
=============================================
  Files           15        17        +2     
  Lines          998      1145      +147     
=============================================
+ Hits           977      1119      +142     
- Misses          21        26        +5
Impacted Files Coverage Δ
pydatastructs/trees/tests/test_heaps.py 100% <100%> (ø)
pydatastructs/trees/__init__.py 100% <100%> (ø) ⬆️
pydatastructs/trees/heaps.py 95.192% <95.192%> (ø)

Impacted file tree graph

@czgdp1807
Copy link
Member

Please add tests as well. Take a look at other modules for coding style.

@23umesh
Copy link
Author

23umesh commented Dec 11, 2019

@czgdp1807 Added test_heaps.py and edited heaps.py to handle extraction on an empty Heap.

Please KWoC label to it.

Parameters
==========

array : list
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to use, OneDimensionalArray.

Copy link
Author

@23umesh 23umesh Dec 11, 2019

Choose a reason for hiding this comment

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

If we use ODA then we have to give our heap size/max_size also. So that we can insert an element in heap.

Implementation -

Parameters:
elements : ODA
Default none.
ODA having initial elements in Heap.
max_size : int
Maximum size of Heap.

Note :
If ODA and max_size passed a new ODA of max_size is formed to hold elements of Heap and passes elements will be copied.

Else passed ODA will determine the size of our heap and we can't insert an element.
Or you want me just pass an ODA and can use the python list to store the elements of the heap.

Copy link
Author

@23umesh 23umesh Dec 11, 2019

Choose a reason for hiding this comment

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

@czgdp1807 What changes you want me to do about this in the code.

Optional, by default 'None'
List of initial elements in Heap

_type : str
Copy link
Member

Choose a reason for hiding this comment

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

Why _?

Copy link
Author

Choose a reason for hiding this comment

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

I thought that as type is manually given by the user so the user knows the type of heap. So made it private.

Returns
==========

element_to_be_extracted : float
Copy link
Member

Choose a reason for hiding this comment

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

It looks like it doesn't need the arguments.

Copy link
Author

Choose a reason for hiding this comment

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

Should i add 'Heap' in the parameters?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's needed.

@czgdp1807
Copy link
Member

Thanks for the updates. I will make a diff and comment it below which you can apply using git apply. I will try to do share the diff by tomorrow evening.

@23umesh
Copy link
Author

23umesh commented Dec 13, 2019

@czgdp1807 Plaease, guide me further on this PR.

@czgdp1807
Copy link
Member

@23umesh Apologies for the delay. I am going to start making changes to it.

@czgdp1807
Copy link
Member

@23umesh I am refactoring your code and it may take quite some time. Feel free to open new issues or work on the existing unassigned ones.

@czgdp1807
Copy link
Member

Make sure to enable, Allow edits from maintainers.

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 this pull request may close these issues.

2 participants