You are on page 1of 50

Data Structure| Important MCQ

Learn and revise Easily

Q1 Which one of the following is an application of stack Data


Structure?

A. Managing function@CSEnigenneringGyan
calls
B. The stock span problem
C. Arithmetic expression evaluation
D. All of the above
Data Structure| Important MCQ
Learn and revise Easily

Q2 Which one of the following is an application of Queue


Data Structure?

A. When a resource@CSEnigenneringGyan
is shared among multiple consumers.
B. When data is transferred asynchronously (data not
necessarily received at same rate as sent) between two
processes
C. Load Balancing
D. All of the above
Data Structure| Important MCQ
Learn and revise Easily

Q3 Which of the following sorting algorithms can be used to


sort a random linked list with minimum time complexity?

A. Insertion Sort @CSEnigenneringGyan


B. Quick Sort
C. Heap Sort
D. Merge Sort
Data Structure| Important MCQ
Learn and revise Easily

Q4 Which of the following is true about linked list


implementation of stack?

A. In push operation, if new nodes are inserted at the beginning of


linked list, then in @CSEnigenneringGyan
pop operation, nodes must be removed from
end.
B. In push operation, if new nodes are inserted at the end, then in
pop operation, nodes must be removed from the beginning.
C. Both of the above
D. None of the above
Data Structure| Important MCQ
Learn and revise Easily

Q5 Which of the following is an advantage of adjacency list


representation over adjacency matrix representation of a graph?

A. In adjacency list representation, space is saved for sparse graphs.


@CSEnigenneringGyan
B. DFS and BSF can be done in O(V + E) time for adjacency list representation.
These operations take O(V^2) time in adjacency matrix representation.
Here is V and E are number of vertices and edges respectively.
C. Adding a vertex in adjacency list representation is easier then adjacency
matrix representation.
D. All of the above
Data Structure| Important MCQ
Learn and revise Easily

Q6 Suppose a circular queue of capacity (n-1) elements is


implemented with an array of n 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 queue full and queue
@CSEnigenneringGyan empty 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
Data Structure| Important MCQ
Learn and revise Easily

Q7 A hash table of length 10 uses open addressing with hash function


h(k)=k mod 10, and linear probing. After inserting 6 values into an empty
hash table. 0
Which one of the following choices gives a possible order in 1
@CSEnigenneringGyan
2 42
which the key values could have been inserted in the table? 3 23
4 34
5 52
A. 46,42,34,52,23,33 6 46
B. 34,42,23,52,33,46 7 33
8
C. 46,34,42,23,52,33
9
D. 42,46,33,23,34,52
Data Structure| Important MCQ
Learn and revise Easily

Q8 A program P reads in 500 integers in the range [0..100]


representing the scores of 500 students. It then prints the
frequency of each score above 50. what would be the best
way for P to store the frequencies? (GATE CS 2005)
@CSEnigenneringGyan
A. An array of 50 numbers
B. An array of 100 numbers
C. An array of 500 numbers
D. A dynamically allocated array of 550 numbers
Data Structure| Important MCQ
Learn and revise Easily

Q9 The key 12,18,13,2,3,23,5 and 15 are inserted into an


initially empty hash table of length 10 using open addressing
with hash function h(k)=k mod 10 and linear probing. What
is the resultant hash table??
@CSEnigenneringGyan
A. A
B. B
C. C
D. D
Data Structure| Important MCQ
Learn and revise Easily

Q10 Suppose the numbers 7,5,1,8,3,6,0,9,4,2 are inserted in


that order into an initially empty binary search tree. The binary
search tree uses the usual ordering on natural numbers. What
is the in-order traversal sequence of the resultant tree??
@CSEnigenneringGyan
A. 7,5,1,0,3,2,4,6,8,9
B. 0,2,4,3,1,6,5,9,8,7
C. 0,1,2,3,4,5,6,7,8,9
D. 9,8,6,4,2,3,0,1,5,7
Data Structure| Important MCQ
Learn and revise Easily

Q11 In the worst case, the number of comparisons needed to


search a singly linked list of length n for a given element is
(GATE CS 2002)
@CSEnigenneringGyan
A. log 2 n
B. n/2
C. log 2 n – 1
D. n
Data Structure| Important MCQ
Learn and revise Easily

Q12 What is the worst case possible height of AVL tree?

A. 2Logn (Assume@CSEnigenneringGyan
base of log is 2)
B. 1.44log n (Assume base of log is 2)
C. Depends upon implementation
D. Theta (n)
Data Structure| Important MCQ
Learn and revise Easily

Q13 Which of the following is AVL Tree?

A. Only A
B. A and C @CSEnigenneringGyan
C. A,B and C
D. Only B
Data Structure| Important MCQ
Learn and revise Easily

Q14 Consider the following left-rotate and right-rotate


functions commonly used in self-adjusting BSTs
Which one of the following is tightest upper bound for left-
rotate and right-rotate operations.
@CSEnigenneringGyan
A. O(1)
B. O(Logn)
C. O(LogLogn)
D. O(n)
Data Structure| Important MCQ
Learn and revise Easily

Q15 Which of the following is FALSE about B/B+ tree_____

A. B/B+ trees grow upword while Binary Search Trees grow


downword.
B. Time complexity of @CSEnigenneringGyan
search operation in B/B+ tree is better then Red
Black Trees in general.
C. Number of child pointers in a B/B+ tree node is always equals to
number of keys in it plus one.
D. A B/B+ tree is defined by a term minimum degree. And minimum
degree depends on hard disk block size, key and address sizes.
Data Structure| Important MCQ
Learn and revise Easily

Q16 Let A be a square matrix of size n x n. Consider the


following program. What is the expected output?

A. The matrix A itself @CSEnigenneringGyan


B. Transpose of matrix A
C. Adding 100 to the upper diagonal elements
and subtracting 100 from diagonal elements of A
D. None of the above
Data Structure| Important MCQ
Learn and revise Easily

Q17 The order of an internal node in a B+ tree index is the


maximum number of children it can have . Suppose that a child
pointer takes 6 bytes, the search field value takes 14 bytes, and the
block size is 512 bytes. What is the order of the internal node?
@CSEnigenneringGyan
A. 24
B. 25
C. 26
D. 27
Data Structure| Important MCQ
Learn and revise Easily

Q18 Consider a complete binary tree where the left and the
right sub-trees of the root are max-heaps. The lower bound
for the number of operations to convert the tree to a heap is
@CSEnigenneringGyan
A. Ω(logn)
B. Ω(n)
C. Ω(nlogn)
D. Ω(n2)
Data Structure| Important MCQ
Learn and revise Easily

Q19 Given a hash table T with 25 slots that stores 2000


elements, the load factor a for T is ____________

A. 80 @CSEnigenneringGyan
B. 0.0125
C. 8000
D. 1.25
Data Structure| Important MCQ
Learn and revise Easily

Q20 Let P be singly linked list. Let Q be the pointer to an


intermediate node x in the list. What is the worst-case time
complexity of the best known algorithm to delete the node Q
from the list?
@CSEnigenneringGyan
A. 0 (n)
B. 0(log2 n)
C. 0(logn)
D. 0(1)
Data Structure| Important MCQ
Learn and revise Easily

Q21 Let G be a weighted undirected graph and e be an edge


with maximum weight in G. Suppose there is a minimum
weight spanning tree in G containing the edge e. Which of the
following statements is always TRUE?
  @CSEnigenneringGyan
A. There exists a cutset in G having all edges of maximum weight.
B. There exists a cycle in G having all edges of maximum weight
C. Edge e cannot be contained in a cycle.
D. All edges in G have the same weight
Data Structure| Important MCQ
Learn and revise Easily

Q22 B+ Trees are considered BALANCED because

A. the lengths of the paths from the root to all leaf nodes are
all equal.
@CSEnigenneringGyan
B. the lengths of the paths from the root to all leaf nodes
differ from each other by at most 1.
C. the number of children of any two non-leaf sibling nodes
differ by at most 1.
D. the number of records in any two leaf nodes differ by at
most 1
Data Structure| Important MCQ
Learn and revise Easily

Q23 When searching for the key value 60 in a binary search tree,
nodes containing the key values 10, 20, 40, 50, 70 80, 90 are
traversed, not necessarily in the order given. How many different
orders are possible in which these key values can occur on the search
path from the root to the node containing the value 60?
@CSEnigenneringGyan
A. 35
B. 64
C. 128
D. 5040
Data Structure| Important MCQ
Learn and revise Easily

Q24 Which of the following is TRUE?

A. The cost of searching an AVL tree is θ (log n) but that of a


binary search tree is O(n)
@CSEnigenneringGyan
B. The cost of searching an AVL tree is θ (log n) but that of a
complete binary tree is θ (n log n)
C. The cost of searching a binary search tree is O (log n ) but
that of an AVL tree is θ(n)
D. The cost of searching an AVL tree is θ (n log n) but that of a
binary search tree is O(n)
Data Structure| Important MCQ
Learn and revise Easily

Q25 Draw the binary tree with node labels a, b, c, d, e,


f and g for which the inorder and postorder traversals result
in the following sequences:
Inorder       a f b c d g e
Postorder   a f c g e d@CSEnigenneringGyan
b
Data Structure| Important MCQ
Learn and revise Easily

Q26 A size-balanced binary tree is a binary tree in which for every


node, the difference between the number of nodes in the left and
right subtree is at most 1. The distance of a node from the root is
the length of the path from the root to the node. The height of a
binary tree is the maximum distance of a leaf node from the
@CSEnigenneringGyan
root. a. Prove, by using induction on h, that a size-balance binary
tree of height h contains at least 2h nodes. b. In a size-balanced
binary tree of height h≤1, how many nodes are at
distance h−1 from the root? Write only the answer without any
explanations.
Data Structure| Important MCQ
Learn and revise Easily

Q27 Consider the following statements:


Which one of the following is correct?
i. First-in-first out types of computations
are efficiently supported by STACKS.
@CSEnigenneringGyan
A. (ii) and (iii) are true ii. Implementing LISTS on linked lists is
more efficient than implementing LISTS
B. (i) and (ii) are true on an array for almost all the basic LIST
operations.
iii. Implementing QUEUES on a circular
C. (iii) and (iv) are true array is more efficient than
implementing QUEUES on a linear array
D. (ii) and (iv) are true with two indices. iv. Last-in-first-out
type of computations are efficiently
supported by QUEUES.
Data Structure| Important MCQ
Learn and revise Easily

Q28 An advantage of chained hash table (external hashing)


over the open addressing scheme is

@CSEnigenneringGyan
A. Worst case complexity of search operations is less
B. Space used is less
C. Deletion is easier
D. None of the above
Data Structure| Important MCQ
Learn and revise Easily

Q29 Let G be the directed, weighted graph shown in below figure


We are interested in the shortest paths from A. (a) Output the
sequence of vertices identified by the Dijkstra’s algorithm for single
source shortst path when the algorithm is started at node A. (b)
Write down sequence@CSEnigenneringGyan
of vertices in the shortest path from A to E.
(c) Wheat is the cost of the shortest path from A to /E?
Data Structure| Important MCQ
Learn and revise Easily

Q30 Which of the following option is not correct?

A. If the queue is implemented with a linked list, keeping track of a


front pointer, Only rear pointer s will change during an insertion
into an non-empty @CSEnigenneringGyan
queue.
B. Queue data structure can be used to implement least recently
used (LRU) page fault algorithm and Quick short algorithm.
C. Queue data structure can be used to implement Quick short
algorithm but not least recently used (LRU) page fault algorithm.
D. Both (A) and (C)
Data Structure| Important MCQ
Learn and revise Easily

Q31 The postorder traversal of a binary tree is 8, 9, 6, 7, 4, 5, 2,


3, 1. The inorder traversal of the same tree is 8, 6, 9, 4, 7, 2, 5,
1, 3. The height of a tree is the length of the longest path from
the root to any leaf. The height of the binary tree above is
________ . Note -This was Numerical Type question.
@CSEnigenneringGyan
A. 2
B. 3
C. 4
D. 5
Data Structure| Important MCQ
Learn and revise Easily

Q32 The minimum number of stacks needed to implement


queue is __________

A. 3 @CSEnigenneringGyan
B. 1
C. 2
D. 4
Data Structure| Important MCQ
Learn and revise Easily

Q33 A B-Tree used as an index for a large database table has


four levels including the root node. If a new key is inserted
in this index, then the maximum number of nodes that
could be newly created in the process are
@CSEnigenneringGyan
A. 5
B. 4
C. 1
D. 2
Data Structure| Important MCQ
Learn and revise Easily

Q34 A three dimensional array in ‘C’ is declared as int A[x][y]


[z]. Consider that array elements are stored in row major
order and indexing begins from 0. Here, the address of an
item at the location A[p][q][r] can be computed as follows
(where w is the word length of an
@CSEnigenneringGyaninteger):

A. &A[0][0][0] + w(y * z * q + z * p + r)
B. &A[0][0][0] + w(y * z * p + z*q + r)
C. &A[0][0][0] + w(x * y * p + z * q+ r)
D. &A[0][0][0] + w(x * y * q + z * p + r)
Data Structure| Important MCQ
Learn and revise Easily

Q35 Consider the following conditions: (a)The solution must be feasible, i.e. it
must satisfy all the supply and demand constraints. (b)The number of
positive allocations must be equal to m1n21, where m is the number of rows
and n is the number of columns. (c)All the positive allocations must be in
independent positions. The initial solution of a transportation problem is
said to be non-degenerate@CSEnigenneringGyan
basic feasible solution if it satisfies: Codes:

A. (a) and (b) only


B. (a) and (c) only
C. (b) and (c) only
D. (a), (b) and (c)
Data Structure| Important MCQ
Learn and revise Easily

Q36 The average depth of a binary search tree is:

A. O(n0.5) @CSEnigenneringGyan
B. O(n)
C. O(log n)
D. O(n log n)
Data Structure| Important MCQ
Learn and revise Easily

Q37 The following numbers are inserted into an empty


binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16.
What is the height of the binary search tree (the height is
the maximum distance of a leaf node from the root)?
@CSEnigenneringGyan
A. 2
B. 3
C. 4
D. 6
Data Structure| Important MCQ
Learn and revise Easily

Q38 The five items: A, B, C, D, and E are pushed in a stack,


one after other starting from A. The stack is popped four
items and each element is inserted in a queue. The two
elements are deleted from the queue and pushed back on
@CSEnigenneringGyan
the stack. Now one item is popped from the stack. The
popped item is
A. A
B. B
C. C
D. D
Data Structure| Important MCQ
Learn and revise Easily

Q39 A full binary tree with n leaves contains:

A. n nodes
@CSEnigenneringGyan
B. log2 n nodes
C. 2n-1
D. 2n
Data Structure| Important MCQ
Learn and revise Easily

Q40 Which of the following correctly declares an array?

A. Int geeks[20];
@CSEnigenneringGyan
B. Int geeks;
C. Geeks{20};
D. Array geeks[20];
Data Structure| Important MCQ
Learn and revise Easily

Q41 Stack A has the entries a,b,c(with a on top). Stack B is


empty. An entry popped out of stack A can be printed
immediately or pushed to stack B. An entry popped out of the
stack can be only be printed. In this arrangement, which of the
following permutations of a,b,c are
@CSEnigenneringGyannot possible?

A. b a c
B. b c a
C. c a b
D. a b c
Data Structure| Important MCQ
Learn and revise Easily

Q42 The five items: A,B,C,D and E are pushed in a stack, one after
other starting from A. The stack is popped four items and each
element is inserted in a queue. The two elements are deleted
from the queue and pushed back on the stack. Now one item is
popped from the stack. The popped item is _________
@CSEnigenneringGyan
A. A
B. B
C. C
D. D
Data Structure| Important MCQ
Learn and revise Easily

Q43 In a file which contains 1 million records and the order


of the tree is 100, then what is the maximum number of
nodes to be accessed if B+ tree index is used?
@CSEnigenneringGyan
A. 5
B. 4
C. 3
D. 10
Data Structure| Important MCQ
Learn and revise Easily

Q44 An array A consists of n integers in locations A[0], A[1] ....A[n-1]. It is


required to shift the elements of the array cyclically to the left by k places,
where 1 <= k <= (n-1). An incomplete algorithm for doing this in linear time,
without using another array is given below. Complete the algorithm by
filling in the blanks. Assume alt the variables are suitably declared.
@CSEnigenneringGyan
A. i > min; j!= (n+i)mod n; A[j + k]; temp; i + 1 ;
B. i < min; j!= (n+i)mod n; A[j + k]; temp; i + 1;
C. i > min; j!= (n+i+k)mod n; A[(j + k)]; temp; i + 1;
D. i < min; j!= (n+i-k)mod n; A[(j + k)mod n]; temp; i + 1;
Data Structure| Important MCQ
Learn and revise Easily

Q45 Consider a hash table of size seven, with starting index zero, and
a hash function (7x+3) mod 4. Assuming the hash table is initially
empty, which of the following is the contents of the table when the
sequence 1, 3, 8, 10 is inserted into the table using closed hashing ?
Here “__” denotes an empty location in the table.
@CSEnigenneringGyan
A. 3, 10, 1, 8, __ , __ , __
B. 1, 3, 8, 10, __ , __ , __
C. 1, __ , 3, __ , 8, __ , 10
D. 3, 10, __ , __ , 8, __ , __
Data Structure| Important MCQ
Learn and revise Easily

Q46 Trie is also known as _________?

A. Treap
@CSEnigenneringGyan
B. Binomial Tree
C. 2-3 Tree
D. Digital Tree
Data Structure| Important MCQ
Learn and revise Easily

Q47 What is the worst case efficiency for a path compression


algorithm?

A. O(M log N) @CSEnigenneringGyan


B. O(N log N)
C. O (log N)
D. O(N)
Data Structure| Important MCQ
Learn and revise Easily

Q48 What is the worst case time complexity of inserting


n2 elements into an AVL-tree with n elements initially ?

A. Θ(n4) @CSEnigenneringGyan
B. Θ(n2)
C. Θ(n2 log n)
D. Θ(n3)
Data Structure| Important MCQ
Learn and revise Easily

Q49 What is the worst case time complexity of inserting n


elements into an empty linked list, if the linked list needs to
be maintained in sorted order ?
@CSEnigenneringGyan
A.Θ(n)
B. Θ(n log n)
C. Θ(n2)
D. Θ(1)
Data Structure| Important MCQ
Learn and revise Easily

Q50 What is the worst-case number of arithmetic operations


performed by recursive binary search on a sorted array of
size n?
@CSEnigenneringGyan
A. Θ(√n)
B. Θ(log2(n))
C. Θ(n2)
D. Θ(n)

You might also like