Q10
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT ( refers to the number of items in the queue)?
Show answer without attempting
Answer: A
GATE CS · Programming and Data Structures · 4 questions
4 Linear Data Structures questions from GATE CS papers (2016), each with the official answer key. Part of Programming and Data Structures. Answer any question right here and it is marked straight away, or practise them one at a time.
Answer: A
int max(int *p, int n) {
int a=0, b=n-1;
while (__________) {
if (p[a] <= p[b]) { a = a+1; }
else { b = b-1; }
}
return p[a];
}Answer: D
while Q is not Empty do
if S is Empty OR Top(S) <= Head(Q) then
x := Dequeue(Q);
Push(S,x);
else
x := Pop(S);
Enqueue(Q,x);
end
endAnswer: 256.0
Answer: C
0/40 correct0 marks