Min Heap in JavaScript
A Min-Heap is a complete binary tree in which the value in each internal node is smaller than or equal to the values in the children of that node. Mapping the elements of a heap into an array is trivial: if a node is stored an index k, then its left child is stored at index 2k + 1 and its right child at index 2k + 2....
read more
Max Heap in JavaScript
A max-heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node. Mapping the elements of a heap into an array is trivial: if a node is stored at index k, then its left child is stored at index 2k + 1 and its right child at index 2k + 2....
read more
Javascript Program To Merge K Sorted Linked Lists – Set 1
Given K sorted linked lists of size N each, merge them and print the sorted output....
read more
Javascript Program To Merge K Sorted Linked Lists Using Min Heap – Set 2
Given k linked lists each of size n and each list is sorted in non-decreasing order, merge them into a single sorted (non-decreasing order) linked list and print the sorted linked list as output.Examples:...
read more
Kth smallest element in a row-wise and column-wise sorted 2D array
Given an n x n matrix, where every row and column is sorted in non-decreasing order. Find the kth smallest element in the given 2D array....
read more
Find the interval which contains maximum number of concurrent meetings
Given a two-dimensional array arr[][] of dimensions N * 2 which contains the starting and ending time for N meetings on a given day. The task is to print a list of time slots during which the most number of concurrent meetings can be held....
read more
Count elements that are greater than at least K elements on its left and right
Given an array arr[] of size n (1 <= n <= 10^5) and a positive integer k, the task is to count all indices i ( 1<= i < n) in the array such that at least k elements to the left of i and at least k elements to the right of i, which are strictly smaller than the value at the ith index (i.e, arr[i])....
read more
Minimize remaining array element by removing pairs and replacing them with their average
Given an array arr[] of size N, the task is to find the smallest possible remaining array element by repeatedly removing a pair, say (arr[i], arr[j]) from the array and inserting the Ceil value of their average....
read more
Binary Heap Notes for GATE Exam [2024]Time Complexity of building a heap:
In the GATE Exam, understanding binary heaps is like having a secret weapon. Questions might ask you to pick the right tool for a job, and heaps are often the superheroes of quick and efficient data organization....
read more
Split the given ranges into two groups
Given a 2D array span[][] of length N which contains spans [L, R] (0 ≤ L ≤ R ≤ 109), the task is to merge those spans which are coinciding and after that split those spans into two groups....
read more
Internal Implementation of Linux Sort Command
Prerequisite:  SORT command in Linux/Unix with examples...
read more
Minimize subtraction of Array elements to make X at most 0
Given a number X, and an array arr[] of length N containing the N numbers. The task is to find the minimum number of operations required to make X non-positive. In one operation:...
read more