# Category Archives: Queue

## Interleave the first half of the queue with second halfAugust 30, 2017

Given a queue of integers of even length, rearrange the elements by interleaving the first half of the queue with the second half of the… Read More »

## Reversing a QueueAugust 20, 2017

Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue. enqueue(x) : Add an item x to rear of… Read More »

## Reversing the first K elements of a QueueAugust 16, 2017

Given an integer k and a queue of integers, we need to reverse the order of the first k elements of the queue, leaving the… Read More »

## Check mirror in n-ary treeJuly 27, 2017

Given two n-ary trees, the task is to check if they are mirror of each other or not. Print “Yes” if they are mirror of… Read More »

## Check if all levels of two trees are anagrams or notJuly 24, 2017

Given two binary trees, we have to check if each of their levels are anagrams of each other or not. Example: Tree 1: Level 0… Read More »

## Stack Permutations (Check if an array is stack permutation of other)July 21, 2017

A stack permutation is a permutation of objects in the given input queue which is done by transferring elements from input queue to the output… Read More »

## Averages of Levels in Binary TreeJuly 14, 2017

Given a non-empty binary tree, print the average value of the nodes on each level. Examples: Input : 4 / \ 2 9 / \… Read More »

## Queue based approach for first non-repeating character in a streamJuly 12, 2017

Given a stream of characters and we have to find first non repeating character each time a character is inserted to the stream. Examples: Input… Read More »

## Program for Page Replacement Algorithms | Set 2 (FIFO)June 17, 2017

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 »

## Minimum sum of squares of character counts in a given string after removing k charactersJune 10, 2017

Given a string of lowercase alphabets and a number k, the task is to print the minimum value of the string after removal of ‘k’… Read More »

## First negative integer in every window of size kJune 8, 2017

Given an array and a positive integer k, find the first negative integer for each and every window(contiguous subarray) of size k. If a window… Read More »

## Level order traversal line by line | Set 2 (Using Two Queues)

Given a Binary Tree, print the nodes level wise, each level on a new line. Output: 1 2 3 4 5 Recommended: Please solve it… Read More »

## Applications of Priority QueueMay 14, 2017

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 »

## Circular Queue | Set 2 (Circular Linked List Implementation)April 25, 2017

Prerequisite – Circular Singly Linked List We have discussed basics and how to implement circular queue using array in set 1. Circular Queue | Set… Read More »

## Circular Queue | Set 1 (Introduction and Array Implementation)April 6, 2017

Prerequisite – Queues Circular Queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and… Read More »