Linear Data Structures questions

Q10

GATE CS 2016 CS-1Linear Data StructuresMCQ1 mark−1/3 if wrong
A queue is implemented using an array such that ENQUEUE and DEQUEUE operations are performed efficiently. Which one of the following statements is CORRECT (nn refers to the number of items in the queue)?
Show answer without attempting

Answer: A

Q34

GATE CS 2016 CS-1Linear Data StructuresMCQ2 marks−2/3 if wrong
The following function computes the maximum value contained in an integer array p[] of size n (n >= 1).
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];
}
The missing loop condition is
Show answer without attempting

Answer: D

Q41

GATE CS 2016 CS-1Linear Data StructuresNAT2 marks
Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.
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
end
The maximum possible number of iterations of the while loop in the algorithm is ________.
Show answer without attempting

Answer: 256.0

Q15

GATE CS 2016 CS-2Linear Data StructuresMCQ1 mark−1/3 if wrong
NN items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed.

An algorithm performs the following operations on the list in this order: Θ(N)\Theta(N) delete, O(log⁡N)O(\log N) insert, O(log⁡N)O(\log N) find, and Θ(N)\Theta(N) decrease-key. What is the time complexity of all these operations put together?
Show answer without attempting

Answer: C

0/40 correct0 marks

Related topics in Programming and Data Structures