0% found this document useful (0 votes)
181 views21 pages

Unit Iv Non-Linear Data Structures Syllabus

This document provides a syllabus and objective type questions related to non-linear data structures including trees, binary trees, binary search trees, set representations, graphs, and their representations. There are 39 multiple choice questions testing concepts like binary tree properties, tree traversals, array and linked list representations of trees, tree construction, and binary search trees.

Uploaded by

Sathya Arul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
181 views21 pages

Unit Iv Non-Linear Data Structures Syllabus

This document provides a syllabus and objective type questions related to non-linear data structures including trees, binary trees, binary search trees, set representations, graphs, and their representations. There are 39 multiple choice questions testing concepts like binary tree properties, tree traversals, array and linked list representations of trees, tree construction, and binary search trees.

Uploaded by

Sathya Arul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

UNIT IV

NON-LINEAR DATA STRUCTURES

SYLLABUS:

Trees – Binary Trees – Binary tree representation and traversals –Binary Search Trees – Applications of trees.
Set representations – Union-Find operations. Graph and its representations – Graph Traversals.
OBJECTIVE TYPE QUESTIONS

1. How many children does a binary tree have?


a) 2
b) any number of children
c) 0 or 1 or 2
d) 0 or 1
Answer: c

2. What is/are the disadvantages of implementing tree using normal arrays?


a) difficulty in knowing children nodes of a node
b) difficult in finding the parent of a node
c) have to know the maximum number of nodes possible before creation of trees
d) difficult to implement
Answer: c

3. What must be the ideal size of array if the height of tree is ‘l’?
a) 2l-1
b) l-1
c) l
d) 2l
Answer: a

4. What are the children for node ‘w’ of a complete-binary tree in an array representation?
a) 2w and 2w+1
b) 2+w and 2-w
c) w+1/2 and w/2
d) w-1/2 and w+1/2
Answer: a

5. What is the parent for a node ‘w’ of a complete binary tree in an array representation when w is not 0?
a) floor(w-1/2)
b) ceil(w-1/2)
c) w-1/2
d) w/2

Answer: a
6. If the tree is not a complete binary tree then what changes can be made for easy access of children of a node
in the array?
a) every node stores data saying which of its children exist in the array
b) no need of any changes continue with 2w and 2w+1, if node is at i
c) keep a seperate table telling children of a node
d) use another array parallel to the array with tree
Answer: a

7. 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
Answer: d

8. Consider a situation of writing a binary tree into a file with memory storage efficiency in mind, is array
representation of tree is good?
a) yes because we are overcoming the need of pointers and so space efficiency
b) yes because array values are indexable
c) No it is not efficient in case of sparse trees and remaning cases it is fine
d) No linked list representation of tree is only fine

Answer: c

9. The following given tree is an examplefor?


a) Binarytree
b) Binary searchtree
c) Fibonacci tree
Answer:a
10. Can a tree stored in an array using either one of inorder or post order or pre order traversals be again
reformed?
a) Yes just traverse through the array and form the tree
b) No we need one more traversal to form a tree
c) No in case of sparse trees
d) Yes by using both inorder and array elements
Answer: b

11. 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
Answer: d

12. Disadvantages of linked list representation of binary trees over arrays?


a) Randomly accessing is not possible
b) Extra memory for a pointer is needed with every element in the list
c) Difficulty in deletion
d) Random access is not possible and extra memory with every element
Answer: d

13. Which of the following traversing algorithm is not used to traverse in a tree?
a) Post order
b) Pre order
c) Post order
d) Randomized
Answer: d

14. Level order traversal of a tree is formed with the help of


a) breadth first search
b) depth first search
c) dijkstra’s algorithm
d) prims algorithm
Answer: a

15. Identify the reason which doesn’t play a key role to use threaded binary trees?
a) The storage required by stack and queue is more
b) The pointers in most of nodes of a binary tree are NULL
c) It is Difficult to find a successor node
d) They occupy less size
Answer: d

16. The following lines talks about deleting a node in a binary tree.(the tree property must not be violated after
deletion)
i) from root search for the node to be deleted
ii)
iii) delete the node at
what must be statement ii) and fill up statement iii)
a) ii)-find random node,replace with node to be deleted. iii)- delete the node
b) ii)-find node to be deleted. iii)- delete the node at found location
c) ii)-find deepest node,replace with node to be deleted. iii)- delete a node
d) ii)-find deepest node,replace with node to be deleted. iii)- delete the deepest node
Answer: d

17. What may be the psuedo code for finding the size of a tree?
a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)
b) find_size(root_node–>left_node) + find_size(root_node–>right_node)
c) find_size(root_node–>right_node) – 1
d) find_size(root_node–>left_node + 1
Answer: a

18. What is missing in this logic of finding a path in the tree for a given sum (i.e checking whether there will be
a path from roots to leaf nodes with given sum)?
checkSum(struct bin-treenode*root , int sum):
if(root==null)
return sum as 0
else:
leftover_sum=sum-root_node-->value
//missing
a) code for having recursive calls to either only left tree or right trees or to both subtrees depending on their
existence
b) code for having recursive calls to either only left tree or right trees
c) code for having recursive calls to either only left tree
d) code for having recursive calls to either only right trees
Answer: a

19. What must be the missing logic below so as to print mirror of a tree as below as an example?

if(rootnode):
mirror(rootnode-->left)
mirror(rootnode-->right)

//missing

end
a) swapping of left and right nodes is missing
b) swapping of left with root nodes is missing
c) swapping of right with root nodes is missing
d) nothing is missing
Answer: a

20. What is the code below trying to print?


void print(tree *root,tree*node)
{
if(root ==null)return0
if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node)
{
print(root->data)
}
}
a) just printing all nodes
b) not a valid logic to do any task
c) printing ancestors of a node passed as argument
d) printing nodes from leaf node to a node passed as argument
Answer: c
21. The number of edges from the root to the node is called __________ of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: b
22. The number of edges from the node to the deepest leaf is called _________ of the tree.
a) Height
b) Depth
c) Length
d) Width
Answer: a

23. What is a full binary tree?


a) Each node has exactly zero or two children
b) Each node has exactly two children
c) All the leaves are at the same level
d) Each node has exactly one or two children
Answer: a

24. What is a complete binary tree?


a) Each node has exactly zero or two children
b) A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from
right to left
c) A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from
left to right
d) A tree In which all nodes have degree 2
Answer: c

25. What is the average case 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)
Answer: d

26. Which of the following is not an advantage of trees?


a) Hierarchical structure
b) Faster search
c) Router algorithms
d) Undo/Redo operations in a notepad
Answer: d

27. In a full binary tree if number of internal nodes is I, then number of leaves L are?
a) L = 2*I
b) L = I + 1
c) L = I – 1
d) L = 2*I – 1
Answer: b

28. In a full binary tree if number of internal nodes is I, then number of nodes N are?
a) N = 2*I
b) N = I + 1
c) N = I – 1
d) N = 2*I + 1
Answer: d

29. In a full binary tree if there are L leaves, then total number of nodes N are?
a) N = 2*L
b) N = L + 1
c) N = L – 1
d) N = 2*L – 1
Answer: d

30. Which of the following is incorrect with respect to binary trees?


a) Let T be a binary tree. For every k ≥ 0, there are no more than 2k nodes in level k
b) Let T be a binary tree with λ levels. Then T has no more than 2λ – 1 nodes
c) Let T be a binary tree with N nodes. Then the number of levels is at least ceil(log (N + 1))
d) Let T be a binary tree with N nodes. Then the number of levels is at least floor(log (N + 1))
Answer: d

31. Construct a binary tree by using postorder and inorder sequences given below.
Inorder: N, M, P, O, Q
Postorder: N, P, Q, O, M
a)
b)
c)
d)
Answer: d

12. Construct a binary search tree by using postorder sequence given below.
Postorder: 2, 4, 3, 7, 9, 8, 5.
a)
b)
c)
d)
Answer: b

32. Construct a binary tree using inorder and level order traversal given below.
Inorder Traversal: 3, 4, 2, 1, 5, 8, 9
Level Order Traversal: 1, 4, 5, 9, 8, 2, 3
a)
b)
c)
d)
Answer: a

33. 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
ANSWER: B

34. The no of external nodes in a full binary tree with n internal nodes is?
a) n
b) n+1
c) 2n
d) 2n + 1
ANSWER: B

35. 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) 2n
ANSWER: D

36. 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
ANSWER: B

37. 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) Every full binary tree is also a complete binary tree
d) A binary tree cannot be both complete and full
ANSWER: C

38. 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
ANSWER : C

39. 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
ANSWER: C

39. Which type of traversal of binary search tree outputs the value in sorted order?
a) Pre-order
b) In-order
c) Post-order
d) None
ANSWER: B

40. 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) 2h -1
d) 2h +1
ANSWER: C
41. 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

42. The number of internal nodes of a 2-3 tree having 9 leaves could be
a) 4
b) 5
c) 6
d) 7
ANSWER: A, D

43. If a node having two children is to be deleted from binary search tree, it is replaced by its
a) In-order predecessor
b) In-order successor
c) Pre-order predecessor
d) None
ANSWER: B

44. 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
ANSWER: D

45. 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) n internal nodes
c) n-1 leaf nodes
d) n-1 internal nodes
ANSWER: B

46. 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) O(n)
c) O(√n)
d) O(log(n))
ANSWER: B

47. 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) Internal nodes
b) External nodes
c) Root nodes
d) None
ANSWER: A
48. 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) Min-heap
ANSWER: D

49. If n elements are sorted in a binary search tree. What would be the asymptotic complexity to search a key in
the tree?
a) O(1)
b) O(logn)
c) O(n)
d) O(nlogn)
ANSWER: C

50. If n elements are sorted in a balanced binary search tree. What would be the asymptotic complexity to
search a key in the tree?
a) O(1)
b) O(logn)
c) O(n)
d) O(nlogn)
ANSWER: B

51. The minimum number of elements in a heap of height h is


a) 2h+1
b) 2h
c) 2h -1
d) 2h-1
ANSWER: B

52. The maximum number of elements in a heap of height h is


a) 2h+1 -1
b) 2h
c) 2h -1
d) 2h -1
ANSWER: A

53. In which of the following tree, parent node has a key value greater than or equal to the key value of both of
its children?
a) Binary search tree
b) Threaded binary tree
c) Complete binary tree
d) Max-heap
ANSWER: D
54. A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is
a) log2n
b) n-1
c) n
d) 2n
ANSWER: B

55. 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) (7, 4)
c) (8, 3)
d) (3, 8)
ANSWER: B

56. Which of the following statements for a simple graph is correct?


a) Every path is a trail
b) Every trail is a path
c) Every trail is a path as well as every path is a trail
d) Path and trail have no relation
Answer: a

57. In the given graph identify the cut vertices.


a) B and E
b) C and D
c) A and E
d) C and B
Answer: d

58. For the given graph(G), which of the following statements is true?
a) G is a complete graph
b) G is not a connected graph
c) The vertex connectivity of the graph is 2
d) The edge connectivity of the graph is 1
Answer: c

59. What is the number of edges present in a complete graph having n vertices?
a) (n*(n+1))/2
b) (n*(n-1))/2
c) n
d) Information given is insufficient
Answer: b
60. The given Graph is regular.
a) True
b) False
Answer: a

61. In a simple graph, the number of edges is equal to twice the sum of the degrees of the vertices.
a) True
b) False

Answer: b
62. A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
a) 15
b) 3
c) 1
d) 11
Answer: b

63. If a simple graph G, contains n vertices and m edges, the number of edges in the Graph G'(Complement of
G) is ___________
a) (n*n-n-2*m)/2
b) (n*n+n+2*m)/2
c) (n*n-n-2*m)/2
d) (n*n-n+2*m)/2
Answer: a

64. Which of the following properties does a simple graph not hold?
a) Must be connected
b) Must be unweighted
c) Must have no loops or multiple edges
d) Must have no multiple edges
Answer: a

65. What is the maximum number of edges in a bipartite graph having 10 vertices?
a) 24
b) 21
c) 25
d) 16
Answer: c

66. Which of the following is true?


a) A graph may contain no edges and many vertices
b) A graph may contain many edges and no vertices
c) A graph may contain no edges and no vertices
d) A graph may contain no vertices and many edges
Answer: b

67. For a given graph G having v vertices and e edges which is connected and has no cycles, which of the
following statements is true?
a) v=e
b) v = e+1
c) v + 1 = e
d) v = e-1
Answer: b

68. For which of the following combinations of the degrees of vertices would the connected graph be eulerian?
a) 1,2,3
b) 2,3,4
c) 2,4,5
d) 1,3,5
Answer: a

69. A graph with all vertices having equal degree is known as a __________
a) Multi Graph
b) Regular Graph
c) Simple Graph
d) Complete Graph

Answer: b

70. 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) No way to represent
Answer: c
71.The inorder traversal of tree will yield a sorted listing of elements oftreein.
A.Binarytrees
B. Binary searchtrees
C. Merging
D. AVL Trees
Answer:b
72.The post order traversal of a binary tree is DEBFCA. Find out the pre order Traversal.
a.ABFCDE
b.ADBFEC
c.ABDECF
d.ABDCEF
Answer: c
73. A graph is said to be ............ If it's edges are assigned data.
a.Tagged
b.Lebeled
C.Marked
d. Sticked
Answer:b

74. Depth First Search is equivalent to which of the traversal in the BinaryTrees?
a)Pre-orderTraversal
b)Post-orderTraversal
c)Level-orderTraversal
d)In-order Traversal Answer:
answer: a

75. Time Complexity of DFS is? (V – number of vertices, E – number ofedges)


a)O(V +E)
b)O(V)
c)O(E)
d)O(V*E)
Answer:a

76. The Data structure used in standard implementation of Breadth First Searchis?
a)Stack
b)Queue
c)LinkedList
d)Tree
Answer:a

77. The Depth First Search traversal of a graph will resultinto?


a)LinkedList
b)Tree
c)Graph with backedges
d)Array
Answer:b

78. A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it
finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he
shoulduse?
a) Depth FirstSearch
b) Breadth FirstSearch
c) Trim’salgorithm
d) Kruskal’sAlgorithm
Answer: a
79. Which of the following is not an application of Depth FirstSearch?
a)For generating topological sort of agraph
b)For generating Strongly Connected Components of a directedgraph
c)Detecting cycles in thegraph
d)Peer to Peer Networks
Answer:d

80. When the Depth First Search of a graph isunique?


a)When the graph is a BinaryTree
b)When the graph is a LinkedList
c)When the graph is a n-aryTree
d)When the graph is a ternary Tree Answer:b
81. Regarding implementation of Depth First Search using stacks, what is the maximum distance between two
nodes present in the stack? (considering each edge length 1)
a)Can beanything
b)0
c)At most1
d) Insufficient Information
Answer:a

82. In Depth First Search, how many times a node isvisited?


a)Once
b)Twice
c)Equivalent to number of indegree of thenode
d)Thrice Answer:c

83. Breadth First Search is equivalent to which of the traversal in the BinaryTrees?
a)Pre-orderTraversal
b)Post-orderTraversal
c)Level-orderTraversal
d)In-order Traversal
Answer:c

84. Which of the following is not an application of Breadth FirstSearch?


a)Finding shortest path between twonodes
b)Finding bipartiteness of agraph
c)GPS navigationsystem
d)Path Finding
Answer:d

85. When the Breadth First Search of a graph isunique?


a)When the graph is a BinaryTree
b)When the graph is a LinkedList
c)When the graph is a n-aryTree
d)When the graph is a TernaryTree
Answer: b

86. Regarding implementation of Breadth First Search using queues, what is the maximumdistance between
two nodes present in the queue? (considering each edge length1)
a)Can beanything
b)0
c)At most1
d)Insufficient Information
Answer:c

87. In BFS, how many times a node isvisited?


a)Once
b)Twice
c)Equivalent to number of indegree of thenode
d)Thrice
Answer:c

88. In order traversing a tree resulted E A C K F H D B G; the preorder traversal


a.FAEKCDBHG
b.FAEKCDHGB
c.EAFKHDCBG
d.FEAKDCHBG
Answer:b

89. In linked representation of Binary trees LEFT[k] contains the ........of at the node N, where k is thelocation.
a.Data
b.Location and left child
c. Right child address
d. Null value
Answer:a

90. Three standards ways of traversing a binary tree T with root R.......
a.Prefix, infix,postfix
b Pre-process, in-process, post-process
c.Pre, in-traversal,post-traversal
d.Pre-order, in-order,post-order
Answer:d

91. Which indicates pre-ordertraversal?


a.Left sub-tree, Right sub-tree and root
b sub-tree, Left sub-tree and root
c Root, Left sub-tree, Right sub-tree
d.Right sub-tree, root, Left sub-tree
Answer:c

92. A terminal node in a binary tree is called ............


a.root
b.Leaf
c.Child
d.Branch
Answer:b

93. Which of the following is the most widely used external memory data structure?
a)AVLtree
b)B-tree
c)Red-blacktree
d)Both AVL tree and Red-blacktree
Answer:b

94. A node can have a minimum of onechild.


a)true
b)false
Answer:a

95. What does the other nodes of an expression tree(except leaves)contain?


a)onlyoperands
b)onlyoperators
c)both operands and operators
d)expression
Answer:b

96. Binary search can be applied on the sorted .


a)array or list.
b)Arguments
c)Queues
d)pointers.
Answer: a

97.An expression tree is createdusing?


a)postfix expression
b)prefixexpression
c)infixexpression
d)paranthesizedexpression
Answer:a

98. Compressiontechniquescanbeusedonthekeystoreducebothspaceandtime requirements in aB-tree.


a)True
b)False
Answer:a

99. Which of the following istrue?


a)larger the order of B-tree, less frequently the splitoccurs
b)larger the order of B-tree, more frequently the splitoccurs
c)smaller the order of B-tree, more frequently the splitoccurs
d)smaller the order of B-tree, less frequently the splitoccurs
Answer:a

100. ++a*bc*+defg is an?


a)postfix expression
b)infixexpression
c)prefixexpression
d)invalidexpression
Answer:c

101. In an expression tree algorithm, what happens when an operand isencountered?


a)create one node pointing to astack
b)pop the nodes from the stack
c)clearstack
d)merge all thenodes
Answer:a

102. An expression tree’s nodes can be deleted bycalling?


a)Malloc
b)calloc
c)delete
d)free
Answer :d

103. What is a threaded binary treetraversal?


a)a binary tree traversal usingstacks
b)a binary tree traversal using queues
c)a binary tree traversal using stacks and queues
d)a binary tree traversal without using stacks and queues
Answer:d

104. What are the disadvantages of normal binary tree traversals?


a)there are many pointers which are null and thus useless
b)there is no traversal which is efficient
c)complexity in implementing
d)improper traversals
Answer:d

105. Which of the following statements for a simple graph is correct?


A. Every path is a trail
B. Every trail is a path
C. Every trail is a path as well as every path is a trail
D. None of the mentioned
Ans : A

106. What is the maximum number of possible non zero values in an adjacency matrix of a simple graph with n
vertices?
A. (n*(n-1))/2
B. (n*(n+1))/2
C. n*(n-1)
D. n*(n+1)
Ans : C

107. 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.
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 than adjacency matrix representation.
D. All of the above
Ans : D

108.A connected planar graph having 6 vertices, 7 edges contains _____________ regions.
A. 15
B. 3
C. 1
D. 11
Ans : B

109.On which of the following statements does the time complexity of checking if an edge exists between two
particular vertices is not, depends?
A. Depends on the number of edges
B. Depends on the number of vertices
C. Is independent of both the number of edges and vertices
D. It depends on both the number of edges and vertices
Ans : C

110. The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in
decreasing order. Which of the following sequences can not be the degree sequence of any graph?
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III.7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1
A. I and II
B. III and IV
C. IV only
D. II and IV
Ans : D

111. What is the maximum number of edges in a bipartite graph having 10 vertices?
A. 24
B. 21
C. 25
D. 16
Ans : C

112. Possible number of labelled simple Directed, Pseudo and Multigarphs exist having 2 vertices?
A. 3, Infinite, 4
B. 4, 3, Infinite
C. 4, Infinite, infinite
D. 4, Infinite, Infinite
Ans : D

113.The most efficient algorithm for finding the number of connected components in an undirected graph on n
vertices and m edges has time complexity.
(A) \theta(n)
(B) \theta(m)
(C) \theta(m + n)
(D) \theta(mn)
A. A
B. B
C. C
D. D
Ans : C

114. What is time complexity to check if a string(length S1) is a substring of another string(length S2) stored in
a Directed Acyclic Word Graph, given S2 is greater than S1?
A. O(S1)
B. O(S2)
C. O(S1+S2)
D. O(1)
Ans : A

115. The no of external nodes in a full binary tree with n internal nodes is?
A. n
B. n+1
C. 2n
D. 2n + 1
Ans : B

116. Which of the following is a true about Binary Trees?


A. Every binary tree is either complete or full.
B. Every complete binary tree is also a full binary tree.
C. Every full binary tree is also a complete binary tree.
D. No binary tree is both complete and full.
E. None of the above
Ans : E

117. A Binary Tree can have


A. Can have 2 children
B. Can have 1 children
C. Can have 0 children
D. All of the above
Ans : D

118.Which of the following is not an advantage of trees?


A. Hierarchical structure
B. Faster search
C. Router algorithms
D. Undo/Redo operations in a notepad
Ans : D

119.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. 2n
Ans : D
120.Finding an element, whether that is present in a list or not. It is called
a)Sorting
b)Searching
c)Storing
d)none
Answer: b

You might also like