Skip to content

Instantly share code, notes, and snippets.

@zeeshan1112
zeeshan1112 / maxHeap.js
Last active September 4, 2023 14:14
Implementation of Max Heap data structure in Javascript
//Implement a max heap in Javascript
/**
* - Implement the constructor
* - Implement the insert() function
* - Implement the getMax() function
* - Implement the removeMax() function
* - Implement the __maxHeapify() function
* - Implement the __bubbleUp() function
* The two underscores before the __bubbleUp() and __maxHeapify() functions imply that these functions should be treated as private functions.
*/
@tpae
tpae / minHeap.js
Last active April 8, 2024 14:14
JavaScript implementation of Min Heap Data Structure
// Implement a min heap:
// -> insert, extract_min
// property:
// - elements are in ascending order
// - complete binary tree (node is smaller than it’s children)
// - root is the most minimum
// - insert takes O(logn) time
// - insert to the bottom right
@paulirish
paulirish / what-forces-layout.md
Last active September 20, 2024 21:16
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent