Convert max heap to min heap in linear time
Given an array representing a max-heap, in-place convert it into the min-heap in linear time.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven an array representing a max-heap, in-place convert it into the min-heap in linear time.
Given an integer array, check if it represents min-heap or not. For example, the first array represents a min-heap, but the second array doesn’t violate the heap property.
Heapsort is an in-place, comparison-based sorting algorithm and can be thought of as an improved selection sort as it divides the input into a sorted and an unsorted region.
Given an array of positive integers, which can be partitioned into three disjoint subsets having the same sum, print the partitions.
In previous post, we have introduced the heap data structure and covered heapify-up, push, heapify-down and pop operations. This article covers C++ implementation of Priority Queue Data Structure (Max Heap and Min heap).
A priority queue is an ADT (Abstract Data Type) for maintaining a set S of elements, with each element having a “priority” associated with it. In a priority queue, an element with high priority is served before an element with low priority or vice versa.
This articles covers stack implementation in C. A stack is a linear data structure that serves as a collection of elements, with three main operations: push, pop and peek.
Given a set of tasks with deadlines and total profit earned on completing a task, find maximum profit earned by executing the tasks within the specified deadlines. Assume that a task takes one unit of time to execute, and it can’t execute beyond its deadline. Also, only a single task will be executed at a time.
This post will discuss the difference between a subarray, a substring, a subsequence, and a subset.
Given a set of activities, along with the starting and finishing time of each activity, find the maximum number of activities performed by a single person assuming that a person can only work on a single activity at a time.
This post will discuss how to search for a given target value in a sorted array of integers using binary search implementation provided by the C++ standard library (STL) and Java Collection framework.
Given a binary array of size two having at least one element as zero, write a single line function to set both its elements to zero. Use of ternary operator and direct assignment of elements are not allowed.