Print Binary Tree levels in sorted order Given a Binary tree, the task is to print its all level in sorted order Examples: Input : ...
Showing posts with label queue. Show all posts
Showing posts with label queue. Show all posts
Sunday, 28 January 2018
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...
Reversing a Queue
Reversing a Queue Give an algorithm for reversing a queue Q. Only following standard operations are allowed on queue. enqueue(x) : ...
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...