Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trekhleb/javascript-algorithms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: aniruddhaadak80/javascript-algorithms
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: patch-4
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Nov 1, 2024

  1. Update MaxHeapAdhoc.js

    Improvements Made:
    
    1. Context Handling: Fixed the issue with the forEach method by using an arrow function to preserve the context of this.
    
    2. Performance Optimization in poll(): Simplified the logic to replace the top element with the last element and directly called heapifyDown() only if the heap is not empty after removing the top.
    
    3. Cleaner heapifyDown() Logic: Streamlined the logic for determining the larger child index. This makes it clearer and avoids unnecessary comparisons.
    
    4. Destructuring in swap(): Used array destructuring for swapping elements, which is more concise and readable.
    
    5. Optional Return Value in peek(): Updated the peek() method to return undefined if the heap is empty, enhancing clarity.
    
    Overall, these changes improve the maintainability, readability, and performance of the code while retaining the core functionality of the max heap data structure.
    
    Thank you .
    aniruddhaadak80 authored Nov 1, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    49e5971 View commit details
Loading