Skip to content

Category Archives: Greedy

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
You are given a string of 2N characters consisting of N ‘[‘ brackets and N ‘]’ brackets. A string is considered balanced if it can… Read More
In previous post, we have discussed Set 1 of SJF i.e. non-preemptive. In this post we will discuss the preemptive version of SJF known as… Read More
Given length of wall w and shelves of two lengths m and n, find the number of each type of shelf to be used and… Read More
Prerequisite : Page Replacement Algorithms In operating systems that use paging for memory management, page replacement algorithm are needed to decide which page needed to… Read More
Prerequisite: Page Replacement AlgorithmsIn operating systems that use paging for memory management, page replacement algorithm are needed to decide which page needed to be replaced… Read More
We have discussed Huffman Encoding in a previous post. In this post decoding is discussed. Examples: Input Data : AAAAAABCCCCCCDDEEEEE Frequencies : A: 6, B:… Read More
In a candy store, there are N different types of candies available and the prices of all the N different types of candies are provided.… Read More
There are N Mice and N holes are placed in a straight line. Each hole can accommodate only 1 mouse. A mouse can stay at… Read More
Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate… Read More
You are given a list of N coins of different denominations. You can pay an amount equivalent to any 1 coin and can acquire that… Read More
Given n objects, with each object has width wi. We need to arrange them in a pyramidal way such that :   Total width of ith… Read More
Given two arrays a[] and b[] of equal length n. The task is to pair each element of array a to an element in array… Read More
Given a string with repeated characters, the task is to rearrange characters in a string so that no two adjacent characters are same.Note : It… Read More
Given a permutation of first n natural numbers as array and an integer k. Print the lexicographically largest permutation after at most k swaps  Examples: … Read More