Comments (6)
@bresson yes, please, just feel free add MaxHeap if you want.
I think it should be added in the same folder as MinHeap. We would need to have an AbstractHeap.js class that will be a base class for the MinHeap.js and MaxHep.js just to avoid code duplication. What do you think?
from javascript-algorithms.
@trekhleb Sounds great! I'll work on a AbstractHeap and MaxHeap first and get a PR, then circle back to refactor MinHeap to inherit from the AbstractHeap.
Quick clarification, Java has dedicated Abstract classes so in JS we're thinking along the lines of following Java's abstract template - a base class which cannot be instantiated and will have abstract and non-abstract methods?
from javascript-algorithms.
@bresson yeah, unfortunately we will need to imitate abstractness. I was thinking about something like this:
class Heap {
constructor() {
if (new.target === Heap) {
throw new TypeError('Cannot construct Heap instance directly');
}
}
// Methods that are common for both Min and Max heaps.
}
class MinHeap extends Heap {
constructor() {
super();
}
// MinHeap specific methods here.
}
Something like that. Just to avoid code duplication. Maybe it is even not abstractness but rather a parent class that just may not be instantiated.
from javascript-algorithms.
Sounds great - aiming for PR in about a week unless work interferes.
from javascript-algorithms.
Hi @bresson, I started to implement MaxHeap before this issue is created.
I have prepared PR #167
but I will change it according to the @trekhleb comment above.
from javascript-algorithms.
Thanks for PR @okersov
from javascript-algorithms.
Related Issues (20)
- NO code available for Longest Increasing Subsequence HOT 6
- How to use the repository HOT 2
- Add Animations to Algorithms
- Binary Search file, comment typo HOT 3
- JS Data structure And Algorithms HOT 1
- priorityQueue does not poll out as expected HOT 4
- Javadcript
- Typo in Portuguese README
- Data structures and algorithms by JavaScript
- Would be great to see `discussions` tab brought to this repository
- JavaScript HOT 3
- Traverse in Reverse is unnecessary complex HOT 4
- Unhandled Edge Case in Binary Search Implementation HOT 1
- `replaceChild` method in BinaryTreeNode is not correct HOT 1
- Pendekatan "Brute Force" dan "Divide and Conquer" HOT 1
- Why this pointing to global context is giving undefined, even when global variable is defined ? HOT 2
- is there support for support for `BigInt` HOT 1
- My dsa roadmap HOT 2
- Ne data project
- Learn HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript-algorithms.