Given two binary max heaps as arrays, the task is to merge the given heaps. Examples : Input: a = {10, 5, 6, 2}, b… Read More
Category Archives: Heap
How to Implement stack using a priority queue(using min heap)?. Asked In: Microsoft, Adobe. Recommended: Please try your approach on {IDE} first, before moving on… Read More
A Priority Queue is different from a normal queue, because instead of being a “first-in-first-out”, values come out in order by priority. It is an… Read More
Given the level order traversal of a Complete Binary Tree, determine whether the Binary Tree is a valid Min-Heap Examples: Input : level = [10,… Read More
Amazon Banglore/Chennai Interview for SDE 1 role Round 1 – Pen Paper Test 1) Root to leaf path sum equal to a given number, number… Read More
Given a string with lowercase repeated characters, the task is to rearrange characters in a string so that no two adjacent characters are the same.… Read More
In previous article, we have discussed about the concepts related to Binomial heap. Examples Binomial Heap: 12------------10--------------------20 / \ / | \ 15 50 70… Read More
A Binary Heap is a Complete Binary Tree. A binary heap is typically represented as array. The representation is done as: The root element will… Read More
Given an array of integers and two numbers k1 and k2. Find the sum of all elements between given two k1’th and k2’th smallest elements… Read More
Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array.… Read More
Eligibility criteria : 70 % OR 7 CGPA and above. Round 1.1 30 aptitude questions in 45 minutes .paper was bit tricky and was at… Read More
The heap data structure can be implemented in a range using STL which provides faster max or min item retrieval, and faster insertion and deletion… Read More
Given K sorted linked lists of size N each, the task is to merge them all maintaining their sorted order. Examples: Input: K = 3,… Read More
Given an array representation of min Heap, convert it to max Heap. Examples: Input: arr[] = {3, 5, 9, 6, 8, 20, 10, 12, 18,… Read More
Prerequisite – Binary Heap K-ary heaps are a generalization of binary heap(K=2) in which each node have K children instead of 2. Just like binary… Read More