MCQS ON DS

DAY-2

STACK & QUEUE:

1. The data structure required to check whether an expression contains balanced parenthesis    is?

        a) Stack                b) Queue        c) Array                d) Tree

2. What is the result of the following operation

    Top (Push (S, X))?

        a) X                b) Null                c) S                d) None

3. Convert the following Infix expression to Postfix form using a stack

    x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression    is legal.

        a) xyz*+pq*r+s*+                b) xyz*+pq*r+s+*

        c) xyz+*pq*r+s*+                d) none

4. A queue is a ?

        a) FIFO (First In First Out) list                 b) LIFO (Last In First Out) list.

        c) Ordered array                        d)Linear tree

5. If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a  time, in            what order will they be removed?

        a) ABCD         b) DCBA        c) DCAB                d) ABCD

DAY-3

LINKED LIST:

1. Which of the following statements about linked list data structure is/are TRUE?

a)Addition and deletion of an item to/ from the linked list require modification of the existing pointers

b) The linked list pointers do not provide an efficient way to search an item in the linked list

c) Linked list pointers always maintain the list in ascending order

d) The linked list data structure provides an efficient way to find kth element in the list

2. The following C Function takes a singly- linked list of integers as a parameter and    rearranges the elements of the lists. The function is called with the list containing    the integers 1,2,3,4,5,6,7 in the given order. What will be the contents of the list    after the function completes execution?

        struct node{ int value;

        struct node* next; };

        void rearrange (struct node* list) {

                struct node *p,q;

        int temp;

        if (! List || ! list->next) return;

        p->list; q=list->next;

        while(q){        

        temp=p->value; p->value=q->value;

        q->value=temp;p=q->next;

        q=p?p->next:0; } }

a) 1, 2, 3, 4, 5, 6, 7                b) 2, 1, 4, 3, 6, 5, 7

c) 1, 3, 2, 5, 4, 7, 6                d) 2, 3, 4, 5, 6, 7, 1

3. The situation when in a linked list START=NULL is ....

        a) Underflow                B) Overflow                C) Houseful                D) Saturated

DAY-4

DOUBLY LINKED LIST:

1. A doubly linked list has .......... pointers with each node.

        a) 0                b) 1                C) 2                D) 3

2. A linear list in which each node has point to the predecessor and successors nodes is    called ........

        a) singly linked list                b) circular linked list

        c) doubly linked list                d) linear linked list

3. A linear list in which each node has point to the predecessor and successors nodes is      called ........

        a) singly linked list                b) circular linked list

        c) doubly linked list                d) linear linked list

DAY-5

SEARCHING:

1. The worst case occur in linear search algorithm when .......

        a) Item is somewhere in the middle of the array

        b) Item is not in the array at all

        c) Item is the last element in the array

        d) Item is the last element in the array or item is not there at all

2. Which of the following is not a limitation of binary search algorithm?

        a) must use a sorted array

        b) requirement of sorted array is expensive when a lot of insertion and deletions                 are needed

        c) there must be a mechanism to access middle element directly

        d) binary search algorithm is not efficient when the data elements more than 1500.

3. Which of the following is not the required condition for binary search algorithm?

        a) The list must be sorted

        b) There should be the direct access to the middle element in any sub list

        c) There must be mechanism to delete and/or insert elements in list.

        d) Number values should only be present

DAY-6

SORTING:

1. Which of the following is not a stable sorting algorithm?

        a) Insertion sort                b) Selection sort

        c) Bubble sort                        d) Merge sort

2. Which of the following algorithm design technique is used in the quick sort algorithm?

        a) Dynamic programming                b) Backtracking

        c) Divide-and-conquer                d) Greedy method

3. A sorting technique is called stable if it

        a)Takes O(nlogn) times

        b)Maintains the relative order of occurrence of non-distinct elements

        c)Uses divide-and-conquer paradigm

d)Takes O(n) space

DAY-7

TREE:

1. The height of a BST is given as h. Consider the height of the tree as the no. of edges    in    the longest path from root to the leaf. The maximum no. of nodes possible in the tree    is?

        a) 2h-1 -1        b) 2h+1 -1        c) 2h +1        d) 2h-1 +1

2. Suppose a binary tree is constructed with n nodes, such that each node has exactly       either zero or two children. The maximum height of the tree will be?

        a) (n+1)/2        b) (n-1)/2        c) n/2 -1        d) (n+1)/2 -1

3. Suppose we have numbers between 1 and 1000 in a binary search tree and want to search     for the number 363. Which of the following sequence could not be the sequence of the    node examined?

        a) 2, 252, 401, 398, 330, 344, 397, 363

        b) 924, 220, 911, 244, 898, 258, 362, 363

        c) 925, 202, 911, 240, 912, 245, 258, 363

        d) 2, 399, 387, 219, 266, 382, 381, 278, 363

ANSWERS :

STACK & QUEUE:

  1. a                2. a                3. a                4. a                5. a

LINKED LIST:

  1. b                2. b                3. a

DOUBLY LINKED LIST:

  1. c                2. c                3. a        

SEARCHING:

  1. d                2. d                3. c

SORTING:

  1. b                2. c                3. b

TREE:

  1. b                2. b                3. c