DS |GATE-2017| PREVIOUS YEAR QUESTIONS| SET-4

Set-13 DS GATE-2008

DS |GATE-2017| Data Structure

1. Consider the C code fragment given below. [GATE – 2017]

typedef struct node   {
    int data;
    node* next;
}  
node;
void join(node* m, node* n)   {
    node*  p = n;
    while(p→next  !=NULL)    {
       p = p→next;
    }
p→next=m;
}

Assuming that m and n point to valid NULL-terminated linked lists, invocation of join will.

a. append list m to the end of list n for all inputs.
b. either cause a null pointer dereference or append list m to the end of list n.
c. cause a null pointer dereference for all inputs.
d. append list n to the end of list m for all inputs.

Answer : b)
DS |GATE-2017|


2. Let be a tree with 10 vertices. The sum of the degrees of all the vertices in T is _________. [GATE – 2017]

a. 15
b. 16
c. 17
d. 18

Answer : d)


3. 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. Which of the following statements is/are CORRECT for such a circular queue, so that insertion and deletion operations can be performed in O(1) time? [GATE – 2017]

I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.

a. I Only
b. II Only
c. Both I and II
d. Neither I and II

Answer : b)
DS |GATE-2017|


4. The Breadth First Search (BFS) algorithm has been implemented using the queue data structure. Which one of the following is a possible order of visiting the nodes in the graph below? [GATE – 2017]

a. MNOPQR
b. NQMPOR
c. POQNMR
d. QMNROP

Answer : c)


5. The pre-order traversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is: [GATE – 2017]

a. 2, 6, 7, 8, 9, 10, 12, 15, 16, 17, 19, 20
b. 2, 7, 6, 10, 9, 8, 15, 17, 20, 19, 16, 12
c. 7, 2, 6, 8, 9, 10, 20, 17, 19, 15, 16, 12
d. 7, 6, 2, 10, 9, 8, 15, 16, 17, 20, 19, 12

Answer : b)
DS |GATE-2017|


Back to GATE-HOME


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *