Data Structures Mcqs
Data Structures Mcqs
1. A word processor to have a PF key that causes the preceding command to be redisplayed and every
time the user presses the PF key, the program shows the command that preceded the one currently
displayed. Which of the following data structures is suitable for implementing this type of word
processor:
a) A Circular Queue
b) An Array
c) A LinkedList
#d) A Stack
e) A Deque
a) Data storage
b) Programmer’s tools
c) modeling
#d) all of the above
e) a only
a) Best case
b) Worst case
#c) Null case
d) Average case
e) None of the above
a) is_empty
b) pop
#c) push
d) peek
e) none of the above
7. A program to receive data that are to be saved and processed in the reverse order can best be
handled by a/an:
a) Array
b) Queue
#c) Stack
d) LinkedList
e) Circular Queue
a) serc
b) carpets
#c) steprac
d) ccaarrppeettss
e) seprac
9. What will be the result of the operation peek for the input “braces”?
a) b
b) c
#c) s
d) a
e) e
Here is an INCORRECT pseudocode for the algorithm which is supposed to determine whether a sequence of
parentheses is balanced:
declare a character stack
while ( more input is available)
{
read a character
if ( the character is a '(' )
push it on the stack
else if ( the character is a ')' and the stack is not empty )
pop a character off the stack
else
print "unbalanced" and exit
}
print "balanced"
10. Which of these unbalanced sequences does the above code think is balanced?
#a) ((())
b) ())(()
c) (()()))
d) (()))()
e) (()))())
11. For the answer in question 10 above how many parenthesis are there in the unbalanced sequence
that the above code think is balanced?
a) 6
b) 7
#c) 5
d) 8
e) None of the above
12. Suppose we have an array implementation of the stack class, with ten items in the stack stored at
data[0] through data[9]. The CAPACITY is 42. Where does the push member function place the new
entry in the array?
a) data[0]
b) data[1]
c) data[9]
#d) data[10]
e) None of the above
13. A data structure used to keep track of the return addresses for nested functions while a program is
running can best be handled by a/an:
a) Queue
#b) Stack
c) LinkedList
d) Deque
e) Array
14. Which of the following data structure is non-linear type?
a) Strings
b) Lists
#c) Stacks
d) None of the above
e) a and b
15. Which of the following data structure is linear type?
a) Strings
b) Lists
c) Queues
#d) All of the above
e) b and c
a) An Array
b) Queue
#c) Stack
d) Deque
e) Linklist
21. The time factor when determining the efficiency of algorithm is measured by
a) Counting microseconds
#b) Counting the number of key operations
c) Counting the number of statements
d) Counting the kilobytes of algorithm
e) Counting the amount of memory used
22. In which location do dynamic variables reside?
23. I have implemented the queue with a linked list, keeping track of a front pointer and a rear
pointer. Which of these pointers will change during an insertion into a NON-EMPTY queue?
a) Neither changes
b) Only front pointer changes.
#c) Only rear pointer changes.
d) Both change.
e) Front pointer will always change during an insertion
24. I have implemented the queue with a linked list, keeping track of a front pointer and a rear
pointer. Which of these pointers will change during an insertion into an EMPTY queue?
a) Neither changes
b) Only front pointer changes.
c) Only rear pointer changes.
#d) Both change
e) Rear pointer will always change
25. Identify the data structure which allows deletions at both ends of the list but insertion at only one
end.
# a) Input-restricted deque
b) Output-restricted deque
c) Priority queues
d) a and b
e) None of above
26. Suppose x is a linked-list node. What is the effect of the following code fragment?
x.next = x.next.next;
#a) Deletes from the list the node immediately following x.
b) Insert into the list a node immediately following x;
c) Deletes the node x from the list
d) Override the contents of node x
e) None of the above
27. Suppose that x is a linked-list node. What is the effect of the following code fragment?
t.next = x.next;
x.next = t;
a) Deletes the node t from the list
#b) Inserts node t immediately after node x.
c) Override the contents of node t
d) Sets the node t to node x
e) None of the above
28. Why does the following code fragment not have the same effect as in the previous question?
x.next = t;
t.next = x.next;
a) A Queue
#b) A Stack
c) A LinkedList
d) An Array
e) Doubly LinkedList
30. A class used to form dynamic data structures that can grow and shrink at execution time is
called :
a) Dynamic class
#b) Self-referential class
c) Reserved class
d) Run-time class
e) None of the above
a) Linkedlist
b) Queue
#c) Array
d) Stack
e) Deque
32. The logical picture of data that shows what the data represent rather than how they are
represented is termed as:
a) Data encapsulation
b) Data mining
c) Data mart
#d) Data abstraction
e) None of the above
a) An array is suitable for homogeneous data but the data items in a record may have different
data type.
b) In a record, there may not be a natural ordering in opposed to linear array.
c) A record form a hierarchical structure but a linear array does not
#d) All of the above
e) None of the above
0267900284
ListHeader
25 30 45 60 65 80 90
ptr1 ptr2
a) 25
b) 60
c) 65
#d) 45
e) 90
a) 80
b) 90
c) 60
d) 65
#e) NULL
a) 45
b) 90
# c) 80
d) 65
e) NULL
37. The memory address of the fifth element of an array can be calculated by the formula:
#a) LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the
array.
b) LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per
memory cell for the array
c) LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the
array.
d) None of above
e) All of above
a) tables arrays
b) matrix arrays
# c) both of above
d) rectangular arrays
e) none of above
40. In the binary search algorithm, what is the precondition to be noted if the algorithm is to produce
the right outputs:
41. The divide and conquer algorithm design consists of how many basic steps:
a) 2
#b) 3
c) 4
d) 5
e) 6
42. Which of the following clearly defines the conquer stage of the Divide and Conquer algorithm
design:
44. The elements of a sparse matrix can best be stored using a/an:
a) Stack
b) Queue
#c) Linkedlist
d) Array
e) Deque
45. What is the word size of each item in bits in an array if the array is to store only double values.
a) 4 bits
b) 8 bits
c) 12 bits
d) 16 bits
#e) 64 bits
Consider the following array declaration and use it to answer questions 46-49:
int A[4][5][6];
46. What will be the total memory in bytes that is to be reserved by the machine to store the data
items in this array:
a) 580 bytes
b) 680 bytes
#c) 480 bytes
d) 380 bytes
e) 280 bytes
47. If the machine is to store the data items in this array using row-major ordering, what will be the
address location of an item located at A[2][3][5] if the base address is 200.
a) 332
b) 846
c) 733
# d) 532
e) 632
48. What will be the address of the same data item in question 47 above if the items in the array
were stored using column-major ordering?
a) 456
b) 650
#c) 656
d) 556
e) 532
49. If the machine is to store the data items in this array using row-major ordering, what will be the
address location of an item located at A[0][0][0] if the base address is 1000.
a) 1081
b) 1078
c) 1243
#d) 1000
e) 1034
50. What is the maximum number of comparisons necessary when performing a binary search of
100,000 items?
a) 13
b) 14
c) 15
d) 16
# e) 17
51. On average, how many items must be moved to delete an item from an unsorted
array with N items?
#a) N/2
b) N/4
c) N/6
d) N/8
e) N/10
52. On average, how many items must be moved to insert a new item into an unsorted
array with N items?
a) N/2
b) N/4
c) N/6
d) N/8
#e) None
53. On average, how many items must be examined to find a particular item in an
unsorted array with N items?
#a) N/2
b) N/4
c) N/6
d) N/8
e) N/10
54. Which of the following statements is true:
55. If there’s only one item in a stack, the bottom of the stack is the same as the top.
a)False
#b)True
56. The OS of a computer may periodically collect all the free memory space to form contiguous
block of free space. This is called
(A) Concatenation
#(B) Garbage collection
(C) Collision
(D) Dynamic Memory Allocation
(E)Disk cleaner
57. The complexity of multiplying two matrices of order m*n and n*p is
#(A) mnp
(B) mp
(C) mn
(D) np
(E)pnm
58. A linear list of elements in which deletion can be done from one end (front) and insertion can
take place only at the other end (rear) is known as a
#(A)queue
(B)stack
(C) trees
(D)linkedlist
(E)array
59. Consider a linked list of n elements. What is the time taken to insert an element after an element
pointed by some pointer?
#(A) O (1)
(B) O ( n log2)
(C) O (n)
(D) O ( n log n 2)
(E)O(2)
62. The data structure required for Breadth First Traversal on a graph is
# (A) queue
(B) stack
(C) array
(D) tree
(E) linkedlist
63. In a linked list with n nodes, the time taken to insert an element after an element pointed by some
pointer is
# (A) 0 (1)
(B) 0 (log n)
(C) 0 (n)
(D) 0 (n 1og n)
(E) O(nlog2n)
65. The data structure required to check whether an expression contains balanced parenthesis is
#(A) Stack
(B) Queue
(C) Tree
(D) Array
(E) LinkedList
66. The complexity of searching an element from a set of n elements using Binary search algorithm
is
(A) O(n)
#(B) O(log n)
(C) O(n2)
(D) O(n log n)
(E) O(nlog2n)
67. What data structure would you mostly likely see in a nonrecursive implementation of a recursive
algorithm?
#(A) Stack
(B) Linked list
(C) Queue
(D) Trees
(E) Array
68. The process of accessing data stored in a serial access memory is similar to manipulating data
on a
(A) linkedlist
(B) queue
#(C) stack
(D) array
(E)heap
69. A linear collection of data elements where the linear node is given by means of pointer is called
#(A) linked list
(B) node list
(C) primitive list
(D) None of these
(E)pointer list
(A) recursive
#(B) abstract data type
(C) storage structure
(D) file structure
(E)linear structure
71. If the address of A[1][1] and A[2][1] are 1000 and 1010 respectively and each element occupies
2 bytes then the array has been stored in _________ order.
73. An ADT is defined to be a mathematical model of a user-defined type along with the collection
of all ____________ operations on that model.
(A) Cardinality
(B) Assignment
#(C) Primitive
(D) Structured
(E)Linear
74. An algorithm is made up of two independent time complexities f (n) and g (n). Then the
complexities of the algorithm is in the order of
(A) f(n) x g(n)
#(B) Max ( f(n),g(n))
(C) Min (f(n),g(n))
(D) f(n) + g(n)
(E)f(n)*( f(n) + g(n))
75. Time complexities of three algorithms are given. Which should execute the slowest for large
values of N?
(A) O(N^0.5)
#(B) O(n)
(C) O(logN)
(D) O(log2n)
(E)O(NlogN)
76. Which of the following operations is performed more efficiently by doubly linked list than by
singly linked list?
77. The extra key inserted at the end of the array of deque is called a,
(A) End key.
(B) Stop key.
#(C) Sentinel.
(D) Transposition.
(E)Tail key
(A) Queue.
#(B) Stack.
(C) Arrays
(D) List.
(E)Trees
81. In binary search, average number of comparison required for searching an element in a list if n
numbers is
# (A) n log2 .
(B) 2/n .
(C) n.
(D) n – 1.
(E)n/2
82. The time required to delete a node x from a doubly linked list having n nodes is
(A) O (n)
(B) O (log n)
# (C) O (1)
(D) O (n log n)
(E)n/2
83. The space factor when determining the efficiency of algorithm is measured by
a) Sorting
b) Merging
c)Inserting
#d) Traversal
e)Searching
85. Finding the location of the element with a given value is:
a)Traversal
#b) Search
c)Sort
d) Merging
e)none of the above
88. Each array declaration need not give, implicitly or explicitly, the information about
a) the name of array
b)the data type of array
#c) the first data from the set to be stored
d) the index set of the array
e)the size of the array
89. The elements of an array are stored successively in memory cells because
#a)by this way computer can keep track only the address of the first element and the
addresses of other elements can be calculated
b) the architecture of computer memory does not allow arrays to store other than serially
c)both of above
d) because the computer memory is linearly structured
e) none of the above
92. Which of the following is not the required condition for binary search algorithm?
95. Which of the following data structure can't store the non-homogeneous data elements?
#a)Arrays
b) Records
c)Pointers
d) LinkedList
e)Trees
96. Which of the following data structure store the homogeneous data elements?
a) Arrays
#b) Records
c) Pointers
d) LinkeList
e) Trees
97. Each data item in a record may be a group item composed of sub-items; those items which are
indecomposable are called
a) elementary items
b) atoms
c) scalars
#d) all of the above
e) none of the above
100. When new data are to be inserted into a data structure, but there is no available space; this
situation is usually called
a) underflow
#b) overflow
c) housefull
d) saturated
e) out of bounds
a) array
b) lists
#c)stacks
d) all of above
e) none of above
105. A data structure where elements can be added or removed at either end but not in the middle:
a) Linked lists
b) Stacks
c)Queues
#d) Deque
e)Trees
106. To represent hierarchical relationship between elements, which data structure is suitable?
a) Deque
b) Priority
#c) Tree
d) All of above
e) none of the above
a) Bubble sort
b) Insertion sort
#c) Quick sort
d) all of the above
e) none of the above
a)Sub algorithm
# b)Recursion
c)Polish notation
d)Traversal algorithm
e)Iterative algorithm
110. Which of the following statements is/are correct in connection with stacks?
(a) Return and remove the most recently inserted item from the stack, if stack is not
empty.
(b) Insert a new item to the top of the stack, if stack is full.
(c) Return and remove the least recently inserted item from the stack, if stack is not
empty.
(d) Linked list based stack implementations are more convenient than array based
implementations.
#(e) a and d only
111. Which of the following is a / are possible operation(s) in connection with stacks?
(a) Reverse the order of elements on stack S using two additional stacks.
(b) Reverse the order of elements on stack S using additional variables.
(c) Reverse the order of elements on stack S using one stack and some additional
queues.
#(d) All of above
(e) none of above
Questions No. 112 and No. 113 are based on the following postfix expression S and the initial values of
the variables.
S=AB-C+DEF-+^
Assume that A=3, B=2, C=1, D=1, E=2, F=3
112. If the above S is evaluated using a stack, what is/are the intermediate value(s) on the top of the
stack?
(a) 3
(b) 0
(c) 2
(d) -1
# (e) all of the above
#(a) 1
(b) 2
(c) 0
(d) -1
(e) 3
Questions No. 114 and No. 115 are based on the following straight queue which can be allocated eight integers
and five operations.
front = 3 rear= 5
Queue = - , - , 2 , 4 ,5, - , - , -
(for notational convenience “ – “ used to denote an empty cell)
The following operations have to be performed.
114. What are the final front and rear values when the above operations are performed into a straight queue?
115. What are the final front and rear values when the above operations are performed into a circular queue?
116. Which of the following are not stack applications in the real world?
117. Queue operations are very similar to stack operations. Which of the following definitions is/are not
suitable for both applications?
# (a) Clear( ) – clear the data structure.
(b) FirstEl(e) – return the 1st element from the relevant application without deleting it.
(c) Is_full( ) – check to see if the application is full.
(d) Is_empty – check to see if the application is empty.
(e) a and b only
118. The data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve this problem we
should:
119. In sequential access data structure, accessing any element in the data structure takes different amount of
time. Tell which one of the following is sequential access data structure:
a) Arrays
b) Lists
c) Both of these
# d) None of these
e) Record