Generate Maximum revenue by selling K tickets from N windows

Objective: Given ‘N’ windows where each window contains certain number of tickets at each window. Price of a ticket is equal to number of tickets remaining at that window. Write an algorithm to sell ‘k’ tickets from these windows in such a manner so that it generates the maximum revenue. This problem was asked in … Read more Generate Maximum revenue by selling K tickets from N windows

Priority Queue in Data Structure

Earlier in we have seen Min-Heap and Max-Heap Implementation. Priority Queue is its built-in implementation in Java. In this article we will see how to perform Min-Heap and Max-Heap using Priority Queue. Brief: A priority queue is an abstract data type where each element has a “priority” assigned to it. So the element with the … Read more Priority Queue in Data Structure

Merge K Sorted Arrays

Objective: Given k sorted array, write an algorithm to merge Them into One sorted array.

Example :

int[][] A = new int[5][];

A[0] = new int[] { 1, 5, 8, 9 };
A[1] = new int[] { 2, 3, 7, 10 };
A[2] = new int[] { 4, 6, 11, 15 };
A[3] = new int[] { 9, 14, 16, 19 };
A[4] = new int[] { 2, 4, 6, 9 };

Output:
[1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 9, 10, 11, 14, 15, 16, 19]

Read moreMerge K Sorted Arrays

Binary Min-Max Heap Implementation

A binary heap is a heap data structure created using a binary tree. binary tree has two rules – Binary Heap has to be a complete binary tree at all levels except the last level. This is called a shape property. All nodes are either greater than equal to (Max-Heap) or less than equal to … Read more Binary Min-Max Heap Implementation