Computer Science Study Materials for Competitive Exams

Sample Questions, Previous Year Solved Papers, Study Materials For Competitive Examinations Like UGC NET, SET And GATE Computer Science.

Saturday, 19 August 2017

Data Structures and Algorithms Multiple Choice Questions - Set 3

21.       Which of the following algorithm is not stable?
(A) Bubble Sort
(B) Quick Sort
(C) Merge Sort
(D) Insertion Sort
Answer: B
22.       An algorithm that requires ................... operations to complete its task on n data elements is said to have a linear runtime.
(A) n3 + 9
(B) 3n2 + 3n + 2
(C) 2n + 1
(D) 9
Answer: C
23.       The in-order traversal of a binary tree is HFIEJGZ, and the post-order traversal of the same tree is HIFJZGE. What will be the total number of nodes in the left sub tree of the given tree? (It is NOT a search tree)
(A) 1
(B) 2
(C) 3
(D) 4
Answer: C
24.       The complexity of adding two matrices of order m*n is
(A) m + n
(B) mn
(C) max(m, n)
(D) min(m, n)
Answer: B
25.       Which method can find if two vertices x & y have path between them?
(A) Depth First Search
(B) Breadth First Search
(C) Both (A) & (B)
(D) None (A) or (B)
Answer: C
26.       If we choose Prim's Algorithm for uniquely weighted spanning tree instead of Kruskal's Algorithm, then
(A) we will get a different spanning tree.
(B) we will get the same spanning tree.
(C) spanning will have less edges.
(D) spanning will not cover all vertices.
Answer: B
Regardless of which algorithm is used, in a graph with unique weight, resulting spanning tree will be same.
27.       The second largest number from a set of n distinct numbers can be found in
(A) O(n)
(B) O(2n)
(C) O(n2)
(D) O(log n)
Answer: A
28.       If the in-order and pre-order traversal of a binary tree are D,B,F,E,G,H,A,C and A,B,D,E,F,G,H,C respectively then the post-order traversal of that tree is
(A) D,F,G,A,B,C,H,E
(B) F,H,D,G,E,B,C,A
(C) C,G,H ,F,E,D,B,A
(D) D,F,H,G,E,B,C,A
Answer: D
29.       In a binary tree, the number of terminal or leaf nodes is 10. The number of nodes with two children is
(A) 9
(B) 11
(C) 25
(D) 20
Answer: A
30.    Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
(A) Insertion Sort
(B) Quick Sort
(C) Heap Sort
(D) Merge Sort
Answer: D

No comments:

Post a Comment