Question Bank - Data Structures

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

MCQS

1. Which of the following data structure is used in recursion ?


a) Stack b) Queue c) Link list d) Tree

2. Which of the following is not an inherent application of stack ?


a) Reversing a string b) Evaluation of postfix expression
c) Implementation of recursion d) Job scheduling

3. What is postfix form of * + A B – C D prefix expression ?


a) A B + * C D – b) A B C + * – c) A B + * C D – d) A B + C D – *

4. Which of the following is an application of stack ?


a) finding factorial b) towers of Hanoi
c) evaluation of postfix expression d) none of the above

5. Stack is a ___________data structure.


a) Non-linear b) Linear
c) Both d) None of the above

6. An infix expression can be converted to a postfix expression using a


a) Stack b) Queue
c) Dequeue d) None of the above

7. Stack cannot be used to


a) Allocate resource and scheduling
b) Implementation of recursion
c) Reverse string
d) Postfix expression evaluation

8. The result of evaluating the postfix expression 123*+4 – is


a) 6 b) 3 c) 10 d) 7

9. Following sequence of operations are performed on a stack.


Push( 1), push( 2 ), pop, push( 1 ), push( 2 ), pop, pop, pop, push( 2 ), pop.
The sequence of popped out values are
a) 2, 2, 1, 1, 2 b) 2, 2, 1, 2, 2
c) 2, 1, 2, 2, 1 d) 2, 1, 2, 2, 2

10.The elements are removed from a stack in ________ order.


a) sequential b) hierarchical
c) alternative d) reverse

11. User performs following operations on stack of size 5, then :


push (1);pop (); push (2); push (3); pop (); push (4); pop (); pop (); push (5);
At the end of last operation, total number of elements present in the stack are :
a) 2 b) 1 c) 4 d) 3

1. Ascending priority queue is one in which the item removed is


a) the smallest item b) the largest item
c) any item d) none

2. Enque operation of queue makes


a) rear = rear + 1 b) front = rear + 1
c) front = rear – 1 d) none of the above

3. The result of an illegal attempt to remove an element from an empty


queue is
a) underflow b) empty c) full d) error

4. What can be said about the array representation of a circular queue when it
contains only one element ?
a) Front = Rear = Null b) Front = Rear + 1
c) Front = Rear – 1 d) Front = Rear

5.Ascending priority queue is one in which the item removed is


a) The item with highest priority b) The item with lowest priority
c) Any item d) None

6. Queue in Data Structure is ___________

a) LIFO b) FIFO c) LILO d) None of these

7. In a circular queue FRONT = REAR indicates


a) queue is full b) queue is empty
c) queue contains only one element d) queue contain some elements

8. Suppose a circular queue of capacity (n –1) elements is implemented with an array of


an elements. Assume that the insertion and deletion operation are carried out using
rear and front as array index variables, respectively. Initially, REAR = FRONT = 0. The
conditions to detect full and empty queue are :
a) full : (rear + 1) mod n = = front, empty : rear = = front
b) full : (rear + 1) mod n = = front, empty : (front + 1) mod n = = rear
c) full : rear = = front, empty : (rear +1) mod n = = front
d) full : (front + 1) mod n = = rear, empty : rear = = front

9. Queues serve major role in


a) simulation of recursion
b) simulation of arbitrary linked list
c) simulation of limited resource allocation
d) all of the above

10. Queue is a _____ data structure


a) Non-linear b) Linear

c)Both d) None

1. In linked lists there are no NULL links in


a) single linked list b) linear doubly linked list
c) circular linked list d) linked list

2. Each node in doubly linked list has _________ fields.


a) 2 b) 3 c) 1 d) 4

3. In linked representation of stack __________ holds the elements of the stack.


a) INFO fields b) TOP fields c) LINK fields d) NULL fields

4. The situation in a linked list when START = NULL means


a) list is created b) list is overflow
c) list is empty d) new node is created

5. The situation when PTR-> NEXT = START in a circular linked list, means
a) PTR is at the first node in the linked list
b) PTR is at the last but one node in the linked list
c) PTR is at the last node in the linked list
d) PTR is at the middle node in the linked list

6. How many files are contained in each node in Doubly linked list
a) atmost 2 b) atleast 3
c) exactly 2 d) none of the above

7. Which of the following operations is performed more efficiently by doubly linked


list than by singly linked list ?
a) Inserting a new mode after node whose location is given
b) Searching of an unsorted list for a given item
c) Deleting a node whose location is given
d) All above

8.In circularly linked list organization, insertion of record involves the modification of
a) No pointer b) 1 pointer c) 2 pointers d) 3 pointers

9.The linear list of element in which delete can be done from one end and insertion can
takes place only at the other end is known as ___________
a) Queue b) Stack c) Tree d) Graph

10.The elements of linked list are stored in


a) Successive memory location b) Random memory location
c) alternate memory location d) Not stored any where

11. In linked lists there are no NULL links in


a) single linked list b) linear doubly linked list
c) circular liked list d) linked list

12.The function free () is used to


a) To unlink first and last node
b) To separate the node from link list
c) To attach a node to other link list
d) To release the memory of node

13. A doubly linked list performs traversal in


a) circular direction b) either direction
c) any direction d) none of these

1. __________traversal of binary search tree outputs the value in sorted order.


a) Pre-order b) In-order
c) Post-order d) None of the above

2. A binary search tree is generated by inserting in order the following integers :


90, 15,62, 120, 98,91,3,8,97,160, 124
a) (4,6) b) (5, 5) c) (3,7) d) None of the above

3. Pre-order traversal is also called

a) Depth first b) Breadth first c) Level order d) In-order

4.The depth of root node is

a) 0 b) 1 c) 2 d) 3

5. In the worst case, a binary search tree will take how much time to search
an elements ?
a) O(n) b) O(log n) c) O(n2) d) O(n log n)

6. A complete binary tree of level 5 (considering root at level 1) has how many nodes?
a) 63 b) 31 c) 15 d) 32

7. Which of the following tree is typically used for “External Search” ?


a) B tree b) AVL tree
c) Red Black tree d) BST
8. Binary trees can have how many children
a) 2 b) any number of children
c) 0 or 1 or 2 d) 0 or 1

9. Advantages of linked list representation of binary trees over arrays?


a) Dynamic size b) Ease of insertion/deletion
c) Ease in randomly accessing a node d) Both dynamic size and ease in insertion/deletion

10. For the tree below, write the post-order traversal.


a) 2, 7, 2, 6, 5,11, 5, 9, 4 b) 2, 7, 5, 2, 6, 9, 5, 11, 4
c) 2, 5, 11, 6, 7, 4, 9, 5, 2 d) 2, 7, 5, 6, 11, 2, 5, 4, 9

11. The number of edges from the root to the node is called _________ of the tree.
a) Height b) Depth c) Length d) None of the mentioned

12. What is the time complexity for finding the height of the binary tree ?
a) h = O(loglogn) b) h = O(nlogn) c) h = O(n) d) h = O(log n)

13. What are null nodes filled with in a threaded binary tree?
a) in order predecessor for left node and inorder successor for right node information
b) right node with inorder predecessor and left node with inorder successor information
c) they remain null
d) some other values randomly

14. Which of the following is false about a binary search tree ?


a) The left child is always lesser than its parent
b) The right child is always greater than its parent
c) The left and right sub-trees should also be binary search trees
d) None of the mentioned

15.The length of the longest path from root to any node is known as ___________
a) Length of Tree b) Width of Tree c) Depth of Tree d) None of above

1.Every internal node of an M-way search tree consists of pointer to M


sub-tree and contains how many keys ?
a) M b) M –1 c) 2 d) M + 1

2.Every node in a B tree has at most ________ children.


a) M b) M –1 c) 2 d) M + 1

3.Consider B+ tree in which the search key is 12 bytes long, block size is1024 bytes, record
pointer is 10 bytes long and block pointer is 8 bytes long. The
maximum number of keys that can be accommodated in each “non-leaf node” of
the tree is
a) 49 b) 50 c) 51 d) 52

4.Nonleaf nodes of B+- tree structure form a


a) Multilevel clustered indices b) Sparse indices
c) Multilevel dense indices d) Multilevel sparse indices
5. In ___________ all leaves are at same level.
a) B+ tree b) B tree
c) Both a) and b) d) Neither a) and b)

6.___________ tree is used to provide indexed sequential file organization.


a) B– Tree b) B+ Tree c) Multiway tree d) None

7. In a B+ tree, in contrast to a B– tree,


S1 : All record are stored at the leaf level of the tree
S2 : Only keys are stored in interior nodes
a) Only S1 is true b) Both are true c) Only S2 is true d) Both are false

1.How much time does an AVL tree take to perform search, insert, and delete operations in the
average case as well as the worst case?
a)O(n) b) O(log n) c) O(n2) d) O(n log n)

2. If we draw an AVL tree using following elements 50, 45, 80, 95, 26, 43, 105,.
What will be balance factor of node 43 in finally produced AVL tree ?
a)0 b) –1 c) +2 d) +1

3.In AVL tree the __________ of node is the height of its left subtree minus the height of its
right subtree.
a) Ordering b) Balanced factor
c) Cardinality d) Multiplicity
4. Why we need to a binary tree which is height balanced ?
a) to avoid formation of skew trees b) to save memory
c) to attain faster memory access d) to simplify storing

5. Given an empty AVL tree, how would you construct AVL tree when a set of numbers are
given without performing any rotations ?
a) just build the tree with the given input
b) find the median of the set of elements given, make it as root and construct the tree
c) use trial and error
d) use dynamic programming to build the tree

6. A balance factor is associated with every node in ___________


a) B–Tree b) B+ Tree c) AVL Tree d) None

7. In AVL tree the ___________ of node is the height of its left subtree minus the height of
its right subtree.
a) Ordering b) Balanced factor
c) Cardinality d) Multiplicity

8. For an AVL tree, if balance factor of any node is 3 then corresponding AVL tree will be
called as
a) Three way tree b) Unbalanced AVL tree
c) 2-3 tree d) Tree-way balanced tree

1. An edge that has identical end-points is called a


a) Multi-path b) Loop c) Cycle d) Multi-edge

2. In a graph if e=[u, v], then u and v are called __________


a) End points of e b) Adjacent nodes
c) Neighbors d) All of the above

3. Topological sort can be apply to only __________


a) Directed Acyclic graph b) Cyclic graph
c) All types of graph d) None of the above

4. Dijkestra Algorithms is used for finding __________


a) Cycle in the graph b) Topological sort
c) Shortest path d) Tree in a graph

5. Which of the following ways can be used to represent a graph ?


a) Adjacency list and adjacency matrix
b) Incidence Matrix
c) Adjacency List, Adjacency Matrix as well as Incidence Matrix
d) None of the mentioned

6. What sequence would the BFS traversal of the given graph yield ?

a) A F D B C E b) C B A F D c) A B D C F d) F D C B A

7.Nodes with same parent is known as


a) Brother nodes b) Siblings c) Children d) None of above

8.A graph which contains a cycle is known as ___________


a) Cyclic graph b) Acyclic graph c) DAG d) All of above

9. The process to visit all the vertices in a graph called as


a) Visiting b) Searching c) Sorting d) Traversing

10. The data structure used in implementation of BFS is?

a) Stack b) Queue

c)Linked List d) None

You might also like