cook the code: queue
Showing posts with label queue. Show all posts
Showing posts with label queue. Show all posts

Sunday, 28 January 2018

Print Binary Tree levels in sorted order

Print Binary Tree levels in sorted order Given a Binary tree, the task is to print its all level in sorted order Examples: Input : ...
Read More

Friday, 29 December 2017

How to efficiently implement k Queues in a single array?

How to efficiently implement k Queues in a single array? We have discussed  efficient implementation of k stack in an array . In thi...
Read More

Reversing a Queue

Reversing a Queue Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue. enqueue(x) : ...
Read More

Implement Stack using Queues

Approach #1 (Two Queues, push -  O(1) O ( 1 ) , pop  O(n) O ( n )  ) Intuition Stack is  LIFO  (last in - first out) data structure, i...
Read More