Skip to content

Category Archives: Heap

Given any sequence, find the largest derangement of .A derangement is any permutation of, such that no two elements at the same position in and are equal. The Largest Derangement… Read More
Binary Heap is a complete tree (All levels are completely filled except possibly the last level and the last level has all keys as left… Read More
Given an array of n positive integers. We are required to write a program to print the minimum product of k integers of the given… Read More
Given an array of integers. Write a program to find the K-th largest sum of contiguous subarray within the array of numbers that has both… Read More
Given a binary min heap and a value x, print all the binary heap nodes having value less than the given value x. Examples :… Read More
Given n tasks with arrival time, priority and number of time units they need. We need to schedule these tasks on a single resource. The… Read More
We are given a list of N unsorted elements, we need to find the minimum number of steps in which the elements of the list… Read More
make_heap() is used to transform a sequence into a heap. A heap is a data structure which points to highest( or lowest) element and making… Read More
INTRODUCTION: A leftist tree, also known as a leftist heap, is a type of binary heap data structure used for implementing priority queues. Like other… Read More
Given that integers are being read from a data stream. Find the median of all the elements read so far starting from the first integer… Read More
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… Read More
Given a stream of integers represented as arr[]. For each index i from 0 to n-1, print the multiplication of largest, second largest, third largest… Read More
Given an array of N numbers and a positive integer K. The problem is to find K numbers with the most occurrences, i.e., the top… Read More
Given a binary search tree which is also a complete binary tree. The problem is to convert the given BST into a Min Heap with… Read More
We have discussed Huffman Encoding in a previous post. In this post, decoding is discussed.  Examples: Input Data: AAAAAABCCCCCCDDEEEEEFrequencies: A: 6, B: 1, C: 6,… Read More