Вы находитесь на странице: 1из 25

Name Ag# Course

Hafiza shumaila 2014-ag-1495 Data structure and


algorithm (CS-707)

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

a. Insertion sort
b b. Selection sort
c. Bubble sort
d Merge sort

Q2. If the given input array is sorted or nearly sorted, which of the following algorithm gives the
best performance?

a a. Insertion sort
b. Selection sort
c. Quick sort
d Merge sort

Q3. Which of the following is a stable sorting algorithm?

a a. Merge sort
b. Typical in-place quick sort
c. Heap sort
d Selection sort

Q4. Which of the following is not an in-place sorting algorithm?

a. Selection sort
b. Heap sort
c. Quick sort
d d Merge sort

Q5. Which of the following algorithm pays the least attention to the ordering of the elements in the
input list?

a. Insertion sort
B b. Selection sort
c. Quick sort
d None

Q6. Consider the situation in which assignment operation is very costly. Which of the following
sorting algorithm should be performed so that the number of assignment operations is
minimized in general?

a. Insertion sort
b b. Selection sort
c. Heap sort
d None

Q7. Merge sort uses

A a. Divide-and-conquer
b. Backtracking
c. Heuristic approach
d Greedy approach

Q8. In full binary search tree every internal node has exactly two children. If there are 100 leaf
nodes in the tree, how many internal nodes are there in the tree?

a. 25
b b. 49
c. 99
d 101

Q9. Which type of traversal of binary search tree outputs the value in sorted order?

a. Pre-order
b. In-order
C c. Post-order
d None

Q10. If a node having two children is to be deleted from binary search tree, it is replaced by its

a. In-order predecessor
b b. In-order successor
c. Pre-order predecessor
d None

Q11. A binary search tree is formed from the sequence 6, 9, 1, 2, 7, 14, 12, 3, 8, 18. The minimum
number of nodes required to be added in to this tree to form an extended binary tree is?

a. 3
b. 6
c. 8
d d 11

Q12. When a binary tree is converted in to an extended binary tree, all the nodes of a binary tree in
the external node becomes

A a. Internal nodes
b. External nodes
c. Root nodes
d None

Q13. A binary search tree is generated by inserting in order the following integers:
50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24
The number of the node in the left sub-tree and right sub-tree of the root, respectively, is

a. (4, 7)
b b. (7, 4)
c. (8, 3)
d (3, 8)

Q14. In a circular linked list

a. Components are all linked together in some sequential manner.


b b. There is no beginning and no end.
c. Components are arranged hierarchically.
d Forward and backward traversal within the list is permitted.

Q15. A linear collection of data elements where the linear node is given by means of pointer is
called?

A a. Linked list
b. Node list
c. Primitive list
d None

Q16. Which of the following operations is performed more efficiently by doubly linked list than by
singly linked list?

A a. Deleting a node whose location in given


b. Searching of an unsorted list for a given item
c. Inverting a node after the node with given location
d Traversing a list to process each node
Q17. Linked lists are not suitable to for the implementation of?

a. Insertion sort
b. Radix sort
c. Polynomial manipulation
D d Binary search

Q18. 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 a. Queue
b. Stack
c. Tree
d Linked list

Q19. The data structure required for Breadth First Traversal on a graph is?

a. Stack
b. Array
C c. Queue
d Tree

Q20. Let the following circular queue can accommodate maximum six elements with the following
data
front = 2 rear = 4
queue = _______; L, M, N, ___, ___
What will happen after ADD O operation takes place?

A a. front = 2 rear = 5
queue = ______; L, M, N, O, ___
b. front = 3 rear = 5
queue = L, M, N, O, ___
c. front = 3 rear = 4
queue = ______; L, M, N, O, ___
d front = 2 rear = 4
queue = L, M, N, O, ___

Q21. A queue is a ?

A a. FIFO (First In First Out) list


b. LIFO (Last In First Out) list.
c. Ordered array
d Linear tree

Q22. In Breadth First Search of Graph, which of the following data structure is used?

a. Stack
B b. Queue
c. Linked list
d None

Q23. 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 a. ABCD
b. DCBA
c. DCAB
d ABCD

Q24. In linked list implementation of a queue, where does a new element be inserted?

a. At the head of link list


B b. At the tail of the link list
c. At the center position in the link list
d None

Q25. In the array implementation of circular queue, which of the following operation take worst case
linear time?

a. Insertion
b. Deletion
c. To empty a queue
D d None

Q26. In linked list implementation of queue, if only front pointer is maintained, which of the
following operation take worst case linear time?

a. Insertion
b. Deletion
c. To empty a queue
D d Both a) and c)

Q27. A circular queue is implemented using an array of size 10. The array index starts with 0, front is
6, and rear is 9. The insertion of next element takes place at the array index.
A a. 0
b. 7
c. 9
d 10

Q28. If the MAX_SIZE is the size of the array used in the implementation of circular queue, array
index start with 0, front point to the first element in the queue, and rear point to the last
element in the queue. Which of the following condition specify that circular queue is EMPTY?

a. Front=rear=0
B b. Front= rear=-1
c. Front=rear+1
d Front=(rear+1)%MAX_SIZE

Q29. A data structure in which elements can be inserted or deleted at/from both the ends but not in
the middle is?

a. Queue
b. Circular queue
C c. Dequeue
d Priority queue

Q30. In linked list implementation of a queue, front and rear pointers are tracked. Which of these
pointers will change during an insertion into a NONEMPTY queue?

a. Only front pointer


B b. Only rear pointer
c. Both front and rear pointer
d None of the front and rear pointer

Q31. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

A a. AB+ CD*E - FG /**


b. AB + CD* E - F **G /
c. AB + CD* E - *F *G /
d AB + CDE * - * F *G /

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

A a. Stack
b. Queue
c. Array
d Tree

Q33. What data structure would you mostly likely see in a non recursive implementation of a
recursive algorithm?

a. LinkList
B b. Stack
c. Queue
d Tree

Q34. The process of accessing data stored in a serial access memory is similar to manipulating data
on a ------?

a. Heap
b. Binary Tree
c. Array
D d Stack

Q35. The postfix form of A*B+C/D is?

a. *AB/CD+
B b. AB*CD/+
c. A*BC+/D
d ABCD+/*

Q36. Which data structure is needed to convert infix notation to postfix notation?

a. Branch
b. Tree
c. Queue
D d Stack

Q37. The prefix form of A-B/ (C * D ⋀ E) is?

a. -/*⋀ACBDE
b. -ABCD*⋀DE
C c. -A/B*C⋀DE
d -A/BC*⋀DE

Q38. What is the result of the following operation


Top (Push (S, X))
A a. X
b. Null
c. S
d None

Q39. The prefix form of an infix expression p + q - r * t is?

a. + pq - *rt
b. - +pqr * t
C c. - +pq * rt
d - + * pqrt

Q40. Which data structure is used for implementing recursion?

a. Queue
B b. Stack
c. Array
d List

Q41. The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?

a. 600
B b. 350
c. 650
d 588

Q42. Convert the following infix expressions into its equivalent postfix expressions
(A + B ⋀D)/(E - F)+G

A a. (A B D ⋀ + E F - / G +)
b. (A B D +⋀ E F - / G +)
c. (A B D ⋀ + E F/- G +)
d None
Q43. 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 a. xyz*+pq*r+s*+
b. xyz*+pq*r+s+*
c. xyz+*pq*r+s*+
d none
Q44. Which of the following statement(s) about stack data structure is/are NOT correct?

a. Stack data structure can be implemented using linked list


b. New node can only be added at the top of the stack
C c. Stack is the FIFO data structure
d The last node at the bottom of the stack has a NULL link

Q45. Consider the linked list implementation of a stack. Which of the following node is considered as
Top of the stack?

A a. First node
b. Last node
c. Any node
d Middle node

Q46. Consider the following operation performed on a stack of size 5.


Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the no of element present on stack are

A a. 1
b. 2
c. 3
d 4

Q47. Which of the following operation take worst case linear time in the array implementation of
stack?

a. Push
b. Pop
c. IsEmpty
D d None

Q48. The type of expression in which operator succeeds its operands is?

a. Infix Expression
b. pre fix Expression
C c. postfix Expression
d None

Q49. Which of the following application generally use a stack?

a. Parenthesis balancing program


b. Syntax analyzer in compiler
c. Keeping track of local variables at run time
D d All of the above

Q50. Consider the following array implementation of stack:


#define MAX 10
Struct STACK
{
Int arr [MAX];
Int top = -1;
}
If the array index starts with 0, the maximum value of top which does not cause stack overflow
is?

A a. 8
b. 9
c. 10
d 11

Q51. What is the minimum number of stacks of size n required to implement a queue of size n?

a. One
B b. Two
c. Three
d Four

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

a. ABCD
B b. DCBA
c. DCAB
d ABDC

Q53. Consider the usual implementation of parentheses balancing program using stack. What is the
maximum number of parentheses that will appear on stack at any instance of time during the
analysis of ( ( ) ( ( ) ) ( ( ) ) )?

a. 1
b. 2
C c. 3
d 4

Q54. The data structure needed to convert a recursion to an iterative procedure is

a. Queue
b. Graph.
C c. Stack
d Tree.

Q55. A binary tree stored using linked representation can be converted to its mirror image by
traversing it in

a. Inorder
B b. Preorder
c. Postorder
d Any order

Q56. The prefix form of an infix expression A+B-C*D is

a. +AB-*CD
b. -+A B C * D
C c. -+A B * C D
d - + *ABCD

Q57. The number of edges in a simple, n-vertex, complete graph is

a. n*(n-2)
b. n*(n-1)
C c. n*(n-1)/2
d n*(n-1)*(n-2)

Q58. The largest and the second largest number from a set of n distinct numbers can be found in

A a. O (n)
b. O (2n)
c. O(2)n
d O (log n)
Q59. The keys 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?

a. A
b. B
c. C
d D

Q60. A binary tree with 45 internal nodes has _________ links to external nodes.

a. 44
b. 45
C c. 46
d 90

Q61. A binary tree with 45 internal nodes has _________ links to external nodes.

a. Root
B b. Leaf
c. Child
d Branch

Q62. Which of the following algorithms can be used to most efficiently determine the presence of a
cycle in a given graph ?

A a. Depth First Search


b. Breadth First Search
c. Prim’s Minimum Spanning Tree Algorithm
d Kruskal’ Minimum Spanning Tree Algorithm
Q63. Traversal of a graph is different from tree because

A a. There can be a loop in graph so we must maintain a visited flag


for every vertex
b. DFS of a graph uses stack, but inorrder traversal of a tree is
recursive
c. BFS of a graph uses queue, but a time efficient BFS of a tree is
recursive.
d All of the above

Q64. What are the appropriate data structures for following algorithms?
1) Breadth First Search
2) Depth First Search
3) Prim's Minimum Spanning Tree
4) Kruskal' Minimum Spanning Tree

a. 1) Stack
2) Queue
3) Priority Queue
4) Union Find
B b. 1) Queue
2) Stack
3) Priority Queue
4) Union Find
c. 1) Stack
2) Queue
3) Union Find
4) Priority Queue
d 1) Priority Queue
2) Queue
3) Stack
4) Union Find

Q65. The Breadth First Search algorithm has been implemented using the queue data structure. One
possible order of visiting the nodes of the following graph is
a. MNOPQR
b. NQMPOR
C c. QMNPRO
d QMNPOR

Q66. Which of the following data structure is non-linear type?

a. Strings
b. Lists
c. Stacks
D d Tree

Q67. The logical or mathematical model of a particular organization of data is called a

A a. Data Structure
b. Data arrangement
c. Data configuration
d Data formation

Q68. The simplest type of data structure is ..................

A a. Multidimensional array
b. Linear array
c. Two dimensional array
d Three dimensional array

Q69. Linear arrays are also called ...................

A a. Straight line array


b. One-dimensional array
c. Vertical array
d Horizontal array

Q70. A ........................ does not keep track of address of every element in the list.

a. Stack
b. String
C c. Linear array
d Queue
Q71. When does top value of the stack changes?

a. Before deletion
b. While checking underflow
c. At the time of deletion
D d After deletion

Q72. In a circular linked list


a. Components are all linked together in some sequential manner
B b. There is no beginning and no end.
c. Components are arranged hierarchically
d Forward and backward traversal within the list is permitted

Q73. . A linear collection of data elements where the linear node is given by means of pointer is
called?

A a. Linked list
b. Node list
c. Primitive list
d None

Q74. Which of the following operations is performed more efficiently by doubly linked list than by
singly linked list?

A a. Deleting a node whose location in given


b. Searching of an unsorted list for a given item
c. Inverting a node after the node with given location
d Traversing a list to process each node

Q75. Consider an implementation of unsorted singly linked list. Suppose it has its representation with
a head and tail pointer. Given the representation, which of the following operation can be
implemented in O(1) time?
i) Insertion at the front of the linked list
ii) Insertion at the end of the linked list
iii) Deletion of the front node of the linked list
iv) Deletion of the last node of the linked list
a. I and II
b. I and III
C c. I,II and III
d I,II and IV

Q76. A variant of linked list in which last node of the list points to the first node of the list is?
a. Singly linked list
b. Doubly linked list
C c. Circular linked list
d Multiply linked list

Q77. In doubly linked lists, traversal can be performed?

a. Only in forward direction


b. Only in reverse direction
C c. In both directions
d None

Q78. What kind of linked list is best to answer question like “What is the item at position n?”

a. Singly linked list


b. Doubly linked list
c. Circular linked list
D d Array implementation of linked list

Q79. 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 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

Q80. Linked lists are not suitable to for the implementation of?

a. Insertion sort
b. Radix sort
c. Polynomial manipulation
D d Binary search

Q81. The memory address of the first element of an array is called

a. floor address
B b. foundation address
c. first address
d base address
Q82. The memory address of fifth element of an array can be calculated by the formula

A 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

Q83. Which of the following data structures are indexed structures?

A a. linear arrays
b. linked lists
c. both of above
d none of above

Q84. 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
sublist
C c. There must be mechanism to delete and/or insert elements in
list
d none of above

Q85. 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 d binary search algorithm is not efficient when the data elements
are more than 1000

Q86. Two dimensional arrays are also called

a. tables arrays
b. matrix arrays
C c. both of above
d none of above
Q87. A variable P is called pointer if

A a. P contains the address of an element in DATA.


b. P points to the address of first element in DATA
c. P can store only memory addresses
d P contain the DATA and the address of DATA

Q88. Which of the following data structure can't store the non-homogeneous data elements?

A a. Arrays
b. Records
c. Pointers
d None

Q89. Which of the following data structure store the homogeneous data elements?

a. Arrays
B b. Records
c. Pointers
d None

Q90. 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 d all of above

Q91. The difference between linear array and a record is

A 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 above

Q92. Which of the following statement is false?

a. Arrays are dense lists and static data structure


b. data elements in linked list need not be stored in adjacent space
in memory
C c. pointers store the next data element of a list
d linked lists are collection of the nodes that contain information
part and next pointer

Q93. Binary search algorithm can not be applied to

A a. sorted linked list


b. sorted binary trees
c. sorted linear array
d pointer array

Q94. 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 b. overflow
c. houseful
d saturated

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

A a. underflow
b. overflow
c. housefull
d saturated

Q96. Which of the following is two way list?

a. grounded header list


b. circular header list
c. linked list with header and trailer nodes
D d none of above

Q97. Which of the following name does not relate to stacks?

A a. FIFO lists
b. LIFO list
c. Piles
d Push-down lists
Q98. The term "push" and "pop" is related to the

a. array
b. lists
C c. stacks
d all of above

Q99. 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 d Deque

Q100. When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return

a. FAEKCDBHG
B b. FAEKCDHGB
c. EAFKHDCBG
d FEAKDCHBG

Q101. Figure out the incorrect statements for pseudo code?

a. Pseudo code is English augmented with programming language


constructs
b. It offers much of the ease and power of expression of English
together with the precision of a programming language
c. There are many versions of pseudo code and no widely accepted
standard
D d None of the mentioned

Q102. What is data structure diagram?

A a. A simple graphical notation is traditionally used to depict data


structures
b. It is a scheme for storing values in computer memory
c. All of the mentioned
d None of the mentioned

Q103. . 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 b. 2h+1 -1
c. 2h +1
d 2h-1 +1

Q104. The no of external nodes in a full binary tree with n internal nodes is?

a. n
B b. n+1
c. 2n
d 2n + 1

Q105. The difference between the external path length and the internal path length of a binary tree
with n internal nodes is?

a. 1
b. n
c. n+1
D d 2n

Q106. 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 b. (n-1)/2
c. n/2 -1
d (n+1)/2 -1

Q107. Which of the following statement about binary tree is CORRECT?

a. Every binary tree is either complete or full


b. Every complete binary tree is also a full binary tree
C c. Every full binary tree is also a complete binary tree
d A binary tree cannot be both complete and full

Q108. 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 c. 925, 202, 911, 240, 912, 245, 258, 363
d 2, 399, 387, 219, 266, 382, 381, 278, 363
Q109. In full binary search tree every internal node has exactly two children. If there are 100 leaf
nodes in the tree, how many internal nodes are there in the tree?

a. 25
b. 49
c. 99
d 101

Q110. Which type of traversal of binary search tree outputs the value in sorted order?

a. Pre-order
B b. In-order
c. Post-order
d None

Q111. Suppose a complete binary tree has height h>0. The minimum no of leaf nodes possible in term
of h is?

a. 2h -1
b. 2h -1 + 1
C c. 2h -1
d 2h +1

Q112. A 2-3 is a tree such that


a) All internal nodes have either 2 or 3 children
b) All path from root to leaves have the same length
The number of internal nodes of a 2-3 tree having 9 leaves could be
a. 4
b. 5
c. 6
d 7

Q113. If a node having two children is to be deleted from binary search tree, it is replaced by its

a. In-order predecessor
B b. In-order successor
c. Pre-order predecessor
d None

Q114. A binary search tree is formed from the sequence 6, 9, 1, 2, 7, 14, 12, 3, 8, 18. The minimum
number of nodes required to be added in to this tree to form an extended binary tree is?
a. 3
b. 6
c. 8
d 11

Q115. In a full binary tree, every internal node has exactly two children. A full binary tree with 2n+1
nodes contains

a. n leaf node
B b. n internal nodes
c. n-1 leaf nodes
d n-1 internal nodes

Q116. the run time for traversing all the nodes of a binary search tree with n nodes and printing them
in an order is

a. O(nlg(n))
B b. O(n)
c. O(√n)
d O(log(n))

Q117. When a binary tree is converted in to an extended binary tree, all the nodes of a binary tree in
the external node becomes

A a. Internal nodes
b. External nodes
c. Root nodes
d None

Q118. If n numbers are to be sorted in ascending order in O(nlogn) time, which of the following tree
can be used

a. Binary tree
b. Binary search tree
c. Max-heap
D d Min-heap

Q119. On which principle does stack work?

A a. FILO
b. FIFO
c. LILO
d Both a and c above
Q120. An empty list is the one which has no

a. nodes
b. data
C c. both a and b above
d address

Q121. In a heap, element with the greatest key is always in the ______________ node

a. leaf
B b. root
c. first node of left sub tree
d first node of right sub tree

Q122. A _____________ tree is tree where for each parent node, there is only one associated child
node

a. balanced binary tree


b. rooted complete binary tree
c. complete binary tree
D d degenerate tree

Q123. Items in a priority queue are entered in a _______________ order

A a. random
b. order of priority
c. as and when they come
d none of the above

Q124. A tree cannot contain cycles

a. False
B b. True

Q125. In graphs, A hyper edge is an edge that is allowed to take on any number of ______

a. Vertices
B b. Edges
c. Both a and b above
d Labels
Q126. Key value pairs is usually seen in

A a. Hash tables
b. Heaps
c. Both a and b
d Skip list

Q127. Breadth First Search is used in

a. Binary trees
b. Stacks
C c. Graphs
d Both a and c above

ANSWERS :

Q1. B Q21. A Q41. B Q61. B Q81. B Q101. D Q121. B


Q2. A Q22. B Q42. A Q62. A Q82. A Q102. A Q122. D
Q3. A Q23. A Q43. A Q63. A Q83. A Q103. B Q123. A
Q4. D Q24. B Q44. C Q64. B Q84. C Q104. B Q124. B
Q5. B Q25. D Q45. A Q65. C Q85. D Q105. D Q125. B
Q6. B Q26. D Q46. A Q66. D Q86. C Q106. B Q126. A
Q7. A Q27. A Q47. D Q67. A Q87. A Q107. C Q127. C
Q8. C Q28. B Q48. C Q68. A Q88. A Q108. C
Q9. B Q29. C Q49. D Q69. A Q89. B Q109. C
Q0. B Q30. B Q50. A Q70. C Q90. D Q110. B
Q11. D Q31. A Q51. B Q71. D Q91. A Q111. C
Q12. A Q32. A Q52. B Q72. B Q92. C Q112. A,D
Q13. B Q33. B Q53. C Q73. A Q93. A Q113. B
Q14. B Q34. D Q54. C Q74. A Q94. B Q114. D
Q15. A Q35. B Q55. B Q75. C Q95. A Q115. B
Q16. A Q36. D Q56. C Q76. C Q96. D Q116. B
Q17. D Q37. C Q57. C Q77. C Q97. A Q117. A
Q18. A Q38. A Q58. A Q78. D Q98. C Q118. D
Q19. C Q39. C Q59. C Q79. B Q99. D Q119. A
Q20. A Q40. B Q60. C Q80. D Q100. B Q120. C

Вам также может понравиться