search
Log In

Recent questions tagged queue

0 votes
0 answers
1
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT($n$ refers to the number of items in the queue)? Both operations can be performed in $O(1)$ time. At most one ... complexity for both operations will be $\Omega(n)$. Worst case time complexity for both operations will be $\Omega(\log n)$.
asked Mar 30 in DS Lakshman Patel RJIT 44 views
2 votes
2 answers
2
A First In First Out queue is a data structure supporting the operation Enque, Deque, Print, Enque(x) adds the item $x$ to the tail of the queue. Deque removes the element at the head of the queue and returns its value. Print prints the head of the queue. You ... in reverse order. If the queue had $n$ elements to begin with, how many statements would you need to print the queue in reverse order?
asked Sep 13, 2019 in DS gatecse 201 views
0 votes
1 answer
3
0 votes
1 answer
4
Whereas a stack allows insertion and deletion of elements at only one end, and a queue allows insertion at one end and deletion at the other end, a deque (double ended queue) allows insertion and deletion at both ends. Write four $O(1)$ time procedures to insert elements into and delete elements from both ends of a deque implemented by an array.
asked Jun 28, 2019 in Algorithms akash.dinkar12 105 views
0 votes
0 answers
5
0 votes
1 answer
6
ENQUEUE(Q, x) 1 Q[Q.tail] = x 2 if Q.tail == Q.length 3 Q.tail = 1 4 else Q.tail = Q.tail + 1 DEQUEUE(Q) 1 x = Q[Q.head] 2 if Q.head == Q.length 3 Q.head = 1 4 else Q.head = Q.head + 1 5 return x illustrate the result of each operation in the sequence ENQUEUE(Q,4),ENQUEUE(Q,1),ENQUEUE(Q,3),DEQUEUE(Q),ENQUEUE(Q,8),DEQUEUE(Q) on an initially empty queue $Q$ stored in array $Q[1...6]$.
asked Jun 28, 2019 in Algorithms akash.dinkar12 92 views
0 votes
0 answers
7
I'm learning data structures from a book. In the topic, Circular Queue using Dynamic Array, the author has mentioned below point, Let capacity be the initial capacity of the circular queue,We must first increase the size of the array using realloc,this will copy maximum ... copies at most capacity elements. But how does array doubling and slide to right copy at most 2 * capacity -2 elements??
asked Apr 14, 2019 in DS Durga Teja 323 views
0 votes
1 answer
8
0 votes
1 answer
9
A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. ... rear node to front. We dont need to do this. So why B is the correct answer?D should be correct ? please explain.
asked Jan 22, 2019 in DS sadiashafaque 60 views
0 votes
1 answer
10
5. Assume I have a stack s, a queue q, and a binary search tree t. Initially all of them are empty. Indicate the state of the data structures at line number 7 and at the end. What is the maximum height each of the data structures had during the execution? 1 i $\rightarrow$ 0 2 while i <= ... $\rightarrow$ 0 8 while i <= 9 do 9 t.insert(s.pop()) 10 t.insert(q.get()) 11 i $\rightarrow$ i + 1 12 end
asked Jan 4, 2019 in DS amit166 114 views
0 votes
0 answers
11
true/false ? ) if stack is implemented as a array,all operation push ,pop ,is emptystack(),delete stack() can be performed in constant time. )if stack is implemented as a linked list ,all operation ,is emptystack(),delete stack() can be performed in constant time.
asked Jan 2, 2019 in Programming Gurdeep Saini 241 views
0 votes
0 answers
12
The array implementation of Queue throws an error when the array limit has been reached. So we consider the following alternative. Create a larger array using redefine function. The cost of the redefine that makes the array larger is proportional to the new size. Suppose we expand the array capacity by one ... of $N$ insertions will take. $O(N^2)$ $O(N^3)$ $O(N)$ $O(log_2N)$ Answer provided: $A$
asked Dec 23, 2018 in DS Gupta731 201 views
0 votes
0 answers
13
Is priority queue work efficiently with sorted array than unsorted array and heap for insertion and deletion operation? Then why do we apply priority queue in heap specially
asked Dec 22, 2018 in DS srestha 174 views
0 votes
1 answer
14
WHAT IS THE TIME COMPLEXITY TO ENQUEUE AN ELEMENT IF THE QUEUE IS IMPLEMENTED AS A CIRCULAR QUEUE AND WE HAVE GOT ONLY ONE POINTER TO FRONT ELEMENT??
asked Sep 20, 2018 in DS sushmita 289 views
0 votes
0 answers
15
1) How many stacks are needed to implement a queue . 2) How many queue are needed to implement a stack.
asked Aug 30, 2018 in DS Shubham Aggarwal 56 views
0 votes
1 answer
16
https://gateoverflow.in/?qa=blob&qa_blobid=11435838562783483664 Approach for Q9 please . (Please note: it is the last question on left hand side, and part of it is written on right hand side) Answer is d, but according to me it should be b as in 3 situation when C is a ... Of elements but won't be restored in it's original state as mentioned in question. So only 1 and 2 is possible. Is it correct?
asked Jul 30, 2018 in DS manvi_agarwal 234 views
0 votes
1 answer
17
0 votes
1 answer
18
What are the minimum number of pointers required to implement a stack using single ended queue ( the queue is NOT a dequeue )?
asked Jul 26, 2018 in DS kapilbk1996 174 views
0 votes
1 answer
19
On other sources, it is given that we need to assign high priorities to newly inserted element in case of stack otherwise low priority to newly inserted element in case of queue. My doubt here is that shouldn't stack be implemented with max-heap priority queue and queue with min-heap priority queue keeping above assumption of assigning priorities to newly inserted element?
asked Jun 17, 2018 in Algorithms pallaviamu 523 views
0 votes
0 answers
20
In implementation of queue using stack, deletion of second element from front take Ο(n) time, when insertion take Ο(1) time. Is it a true statement ? Well it can be true isn't it ? because suppose elements come we simply push them without taking care of the order in ... everything back to stack1. dnQueue(q) 1) If stack1 is empty then error 2) Pop an item from stack1 and return it Am i right?
asked May 5, 2018 in Programming Na462 553 views
0 votes
1 answer
21
Its GATE 2013 question Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter. MultiDequeue(Q){ m = k while (Q is not empty) and (m > 0) { Dequeue(Q) m = m - 1 } } What is the worst case time complexity of a sequence ... are performed on non-empty or full queue?? Due to this change will the answer remain same?? Θ(n) Θ(n + k) Θ(nk) Θ(n2)
asked May 1, 2018 in DS !KARAN 222 views
0 votes
1 answer
22
Consider implementation of stack using queue by following algorithm. Let $x$ be an element to be pushed in the stack push(q1,x) { EQ(q1,x) while(q1 does not contain 1 element) { k=DQ(q1) EQ(q1,k) } } pop(q1) { DQ(q1) } How many enqueue and dequeue operations required to push $2$ and pop $2$ elements in the empty stack?
asked Apr 30, 2018 in DS himgta 245 views
0 votes
1 answer
23
Hi please verify me We can implement a stack using only one queue. Like first insert into queue and for popping a element from stack dequeue n-1 element from queue and enque into queue and then pop last element and do the same each time......try it and verify that I am right or wrong?
asked Apr 7, 2018 in Programming Ravi prakash pandey 406 views
21 votes
5 answers
24
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let $n$ denote the number of nodes in the queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue' be implemented by deletion of a ... ? $\Theta(1), \Theta(1)$ $\Theta(1), \Theta(n)$ $\Theta(n), \Theta(1)$ $\Theta(n), \Theta(n)$
asked Feb 14, 2018 in DS gatecse 4.7k views
0 votes
2 answers
25
A queue is implemented using two stacks S1 and S2. Initially the queue contains 1, 2, 3, 4 from front to rear. The following operations are performed in the queue: delete, insert (5), delete, Then how many total no. of push and pop operations are needed to perform the above operation? a) Push: 12 Pop: 13 b) Push: 15 Pop: 16 c) Push: 11 Pop: 10 d) Push: 12 Pop: 11
asked Jan 31, 2018 in DS Tuhin Dutta 272 views
0 votes
1 answer
26
Consider the following statements: S1 : Implementation of stack using queue, deletion of second element from top of stack time complexity Ο(n), when insertion take Ο(1) time. S2 : In implementation of queue using stack, deletion of second element from front take Ο(1) ... take Ο(n) time. Both the statements are true. HOW? Kindly provide a detailed explanation. I am unable to solve such questions.
asked Jan 31, 2018 in DS _jerry 398 views
2 votes
1 answer
27
Consider the following statements: S1: If stack is implemented as an array, all the operation push, pop, is_empty stack ( ), delete stack ( ) can be performed in constant time. S2: If stack is implemented as a linked list, all the operations is_empty stack, ... data structure. S4: Circular queues can be implemented with the help of the stack data structure. Which of the following option is false?
asked Jan 23, 2018 in DS Rishabh Gupta 2 486 views
3 votes
1 answer
28
In implementation of queue using stack, deletion of second element from front take Ο(1) time, when insertion take Ο(n) time. Which of the following is correct ? True / False
asked Jan 20, 2018 in Algorithms Hemant Parihar 564 views
...