0% found this document useful (0 votes)
12 views

DSA Practice Set

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

DSA Practice Set

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICE SET

1. A binary search tree whose left sub tree and right (e) None of these
sub tree differ in height by at most 1 unit is 12. To represent hierarchical relationship between
called …… elements, Which data structure is suitable?
(a) AVL tree (b) Red-black tree (a) Dequeue (b) Priority
(c) Lemma tree (d) None of the above (c) Tree (d) Graph
(e) Both (a) and (b) (e) None of these
2. ……………….. level is where the model becomes 13. Which data structure is used in breadth first search
compatible executable code of a graph to hold nodes?
(a) Abstract level (b) Application level (a) Stack (b) Queue
(c) Implementation level (c) Tree (d) Array
(d) All of the above (e) None of these (e) None of these
3. Stack is also called as 14. In a stack, if a user tries to remove an element from
(a) Last in first out (b) First in last out empty stack it is called _________
(c) Last in last out (d) First in first out (a) Underflow (b) Empty collection
(e) None of these (c) Overflow (d) Garbage Collection
4. Which of the following is true about the (e) None of these
characteristics of abstract data types? 15. The disadvantage in using a circular linked list
(i) It exports a type. is …………………….
(ii) It exports a set of operations (a) It is possible to get into infinite loop.
(a) True, False (b) False, True (b) Last node points to first node.
(c) True, True (d) False, False (c) Time consuming
(e) None of these (d) Requires more memory space
5. …………… is not the component of data structure. (e) None of these
(a) Operations (b) Storage Structures 16. Deletion operation is done by using ……… in a
(c) Algorithms (d) None of above queue.
(e) Programming (a) Front (b) Rear
6. Inserting an item into the stack when stack is not full (c) Top (d) List
is called …………. Operation and deletion of item (e) None of these
form the stack, when stack is not empty is 17. Heap can be used as…
called ………..operation. (a) Priority queue (b) Stack
(a) Push, pop (b) Pop, push (c) A decreasing order array
(c) Insert, delete (d) Delete, insert (d) None of these (e) A increasing order array
(e) None of these 18. Which of the following is true?
7. ……………. Is a pile in which items are added at one (a) A graph may contain no edges and many vertices
end and removed from the other. (b) A graph may contain many edges and no vertices
(a) Stack (b) Queue (c) A graph may contain no edges and no vertices
(c) List (d) None of the above (d) None of these
(e) Zoom (e) All of the above
8. ………… is very useful in situation when data have 19. Quick Sort can be categorized into which of the
to stored and then retrieved in reverse order. following?
(a) Stack (b) Queue (a) Brute Force technique (b) Divide and conquer
(c) List (d) Link list (c) Greedy algorithm
(e) None of these (d) Dynamic programming (e) None of these
9. Which data structure allows deleting data elements 20. What is the worst case complexity of Quick Sort?
from and inserting at rear? (a) O(nlogn) (b) O(logn)
(a) Stacks (b) Queues (c) O(n) (d) O(n2)
(c) Dequeues (d) Binary search tree (e) None of these
(e) None of these 21. The number of comparisons done by sequential
10. Which of the following data structure can’t store the search is ………………
non-homogeneous data elements? (a) (N/2)+1 (b) (N+1)/2
(a) Arrays (b) Records (c) (N-1)/2 (d) (N+2)/2
(c) Pointers (d) Stacks (e) None of these
(e) None of these 22. In ……………, search start at the beginning of the list
11. Which of the following is non-liner data structure? and check every element in the list.
(a) Stacks (b) List (a) Linear search (b) Binary search
(c) Strings (d) Trees (c) Hash Search (d) Binary Tree search
(e) None of these (c) O(n log n) (d) O(n2)
23. State True or False. (e) None of these
(i) Binary search is used for searching in a sorted 34. Which algorithmic technique does Fibonacci search
array. use?
(ii) The time complexity of binary search is O(log n). (a) Brute force (b) Divide and Conquer
(a) True, False (b) False, True (c) Greedy Technique (d) Backtracking
(c) False, False (d) True, True (e) None of these
(e) None of these 35. Depth First Search is equivalent to which of the
24. Which of the following is not the internal sort? traversal in the Binary Trees?
(a) Insertion Sort (b) Bubble Sort (a) Pre-order Traversal (b) Post-order Traversal
(c) Merge Sort (d) Heap Sort (c) Level-order Traversal
(e) None of these (d) In-order Traversal (e) None of these
25. State True or False. 36. Time Complexity of DFS is? (V – number of vertices,
(i) An undirected graph which contains no cycles is E – number of edges)
called forest. (a) O(V + E) (b) O(V)
(ii) A graph is said to be complete if there is an edge (c) O(E) (d) None of these
between every pair of vertices. (e) Both (b) and (c)
(a) True, True (b) False, True 37. The Data structure used in standard implementation
(c) False, False (d) True, False of depth first search is?
(e) None of these (a) Stack (b) Queue
26. What is the time complexity of inserting at the end in (c) Linked List (d) None of these
dynamic arrays? (e) Both (a) and (b)
(a) O(1) (b) O(n) 38. The complexity of sorting algorithm measures
(c) O(log n) (d) Either O(1) or O(n) the ..…… as a function of the number n of items to
(e) None of these be sorter.
27. Linked lists are not suitable to for the (a) Average time (b) Running time
implementation of? (c) Average-case complexity
(a) Insertion sort (b) Radix sort (d) Case-complexity (e) None of these
(c) Polynomial manipulation 39. If the number of records to be sorted is small,
(d) Binary search (e) None of these then …… sorting can be efficient.
28. Linked list data structure offers considerable saving (a) Merge (b) Heap
in (c) Selection (d) Bubble
(a) Computational Time (b) Space Utilization (e) None of these
(c) Space Utilization and Computational Time 40. Partition and exchange sort is ……..
(d) None of these (e) Both (a) and (c) (a) Quick sort (b) Tree sort
29. Which of the following sorting algorithms can be (c) Heap sort (d)Bubble sort
used to sort a random linked list with minimum time (e) None of these
complexity? 41. In ………… ; for any node n, every descendant
(a) Insertion Sort (b) Quick Sort node’s value in the left sub tree of n is less than the
(c) Heap Sort (d) Merge Sort value of n and every descendant node’s value in the
(e) None of these right sub tree is greater than the value n.
30. The time complexity of quick sort is ………….. (a) Binary tree (b) Binary search tree
(a) O(n) (b) O(n2) (c) AVL tree (d) Binary heap tree
(c) O(n log n) (d) O(log n) (e) None of these
(e) None of these 42. In the best case of BST, the time is on the order
31. In a priority queue, insertion and deletion takes of …………, but in the worst case it requires linear
place at ……………… time.
(a) Front, rear end (b) Only at rear end (a) log₂n (b) n
(c) Only at front end (d) Any position (c) log₂(n+1) (d) n+1
(e) None of these (e) None of these
32. While deleting nodes from a binary heap, ………. 43. …………………. of binary search tree starts by
node is replaced by the last leaf in the tree. visiting the current node, then its left child and then
(a) Left leaf (b) Right leaf its right child.
(c) Root (d) Cycle (a) Preorder traversal (b) In-order traversal
(e) None of these (c) Linear traversal (d) Post-order traversal
33. The worst case complexity of deleting any arbitrary (e) None of these
node value element from heap is 44. State True or False for internal sorting algorithms.
(a) O(log n) (b) O(n)
(i) Internal sorting are applied when the entire (a) galloc () (b) falloc ()
collection if data to be sorted is small enough that (c) malloc () (d) calloc ()
the sorting can take place within main memory. (e) None of these
(ii) The time required to read or write is considered 53. Which of the following statements is/are TRUE for
to be significant in evaluating the performance of an undirected graph?
internal sorting. (i) Number of odd degree vertices is even
(a) i-True, ii-True (b) i-True, ii-False (ii) Sum of degrees of all vertices is even
(c) i-False, ii-True (d) i-False, ii-False (a) Only I (b) Only ii
(e) None of these (c) Both i and ii (d) Neither i nor ii
45. The height of a tree is the length of the longest (e)None of these
root-to-leaf path in it. The maximum and minimum 54. The Average case occurs in linear search
number of nodes in a binary tree of height 5 is. algorithm ……….
(a) 63 and 6, respectively (a) When item is somewhere in the middle of the
(b) 64 and 5, respectively array
(c) 32 and 6, respectively (b) When item is not the array at all
(d) 31 and 5, respectively (c) When item is the last element in the array
(e) None of these (d) Item is the last element in the array or item is not
46. In a binary tree, the number of internal nodes of there at all
degree 1 is 5, and the number of internal nodes of (e) None of these
degree 2 is 10. The number of leaf nodes in the 55. Which of the following is not the required condition
binary tree is for binary search algorithm?
(a) 10 (b) 11 (a) The list must be sorted
(c) 12 (d) 15 (b) There should be the direct access to the middle
(e) None of these element in any sub list
47. Breadth First Search (BFS) is started on a binary tree (c) There must be mechanism to delete and/or insert
beginning from the root vertex. There is a vertex t at elements in list.
a distance four from the root. If t is the n-th vertex in (d) Both (b) and (a)
this BFS traversal, then the maximum possible value (e) None of these
of n is ________ 56. For a linear search in an array of n elements the time
(a) 15 (b) 16 complexity for best, worst and average case
(c) 31 (d) 32 are ....... , ........ and ........ respectively.
(e) None of these (a) O(n), O(1), and O(n/2)
48. The maximum number of binary trees that can be (b) O(1), O(n) and O(n/2) (c) O(1),O(n) and O(n)
formed with three unlabeled nodes is: (d) O(1), O(n) and (n-1/2) (e) None of these
(a) 1 (b) 5 57. Which of the following sorting methods will be the
(c) 4 (d) 3 best if number of swapping done, is the only
(e) None of these measure of efficiently?
49. When does top value of the stack changes? (a) Bubble sort (b) Selection sort
(a) Before deletion (c) Insertion sort (d) Quick sort
(b) While checking underflow (e) None of these
(c) At the time of deletion 58. The maximum number of comparisons needed to
(d) After deletion (e) None of these sort 7 items using radix sort is (assume each item is 4
50. ……………… is known as a greedy algorithm, digit decimal number)
because it chooses at each step the cheapest edge to (a) 280 (b) 40
add to sub graph S. (c) 47 (d) 38
(a) Kruskal’s algorithm (b) Prim’s algorithm (e) None of these
(c) Dijkstra algorithm (d) Bellman ford algorithm 59. Which of the following statements are correct?
(e) None of these I. If each tree node contains a father field, then it's not
51. The result of prim’s algorithm is a total time bound necessary to use either stack or threads
of ……………… II. Traversal using father pointers is more time efficient
(a) O(log n) (b) O(m + n log n) than traversal of a threaded tree
(c) O(mn) (d) O(m log n) III. A in-threaded binary tree is defined as binary tree
(e) None of these that is both left-in threaded and right-in threaded.
52. Which function plays an important role in returning (a) II and III (b) I and III
the address of memory block allocated to locate / (c) I and II (d) None of these
store a node especially while declaring ' top ' in the (e) Both (a) and (b)
linked representation of the Stack?
- Published on 28 Aug 15
60. If each node in a tree has value greater the every (c) Binary search tree (d) AVL tree
value in its left sub tree and has value less than every (e) None of these
value in its right sub tree, the tree is called
(a) Complete tree (b) Full binary tree
SOLUTIONS

1. (a) 38. (b)


2. (c) 39. (c)
3. (a) 40. (a)
4. (c) 41. (b)
5. (d) 42. (a)
6. (a) push, pop 43. (a); Preorder traversal
7. (b) Queue 44. (b)
8. (a) 45. (a); Number of nodes is maximum for a perfect
9. (b) Queues binary tree.
10. (a) A perfect binary tree of height h has 2h+1 - 1 nodes
11. (d) Number of nodes is minimum for a skewed binary
12. (c) tree.
13. (b) A perfect binary tree of height h has h+ 1 node.
14. (a) 46. (b); In a binary tree, the number of leaf nodes is
15. (a) It is possible to get into infinite loop. always 1 more than number of internal nodes with 2
16. (a) children
17. (a); The property of heap that the value of root must So,
be either greater or less than both of its children Number of Leaf Nodes = Number of Internal nodes
makes it work like a priority queue. with 2 children + 1
18. (b) Number of Leaf Nodes = 10 + 1
19. (b) Number of Leaf Nodes = 11
20. (d) 47. (c); t is the nth vertex in this BFS traversal at distance
21. (b) four from the root. So height of tree is 4.
22. (a) Max number of nodes = 2h+1 − 1 = 31
23. (d) At distance four, last node is 31.
24. (c) 48. (b)
25. (a) 49. (d)
26. (d) 50. (b)
27. (d) 51. (a)
28. (c) 52. (c)
29. (d) 53. (c)
30. (c) 54. (a)
31. (d) 55. (c)
32. (c) 56. (c)
33. (a) 57. (b); Because in selection sort algorithm we randomly
34. (b) access data rather than a list in which we can easily
35. (a); In Depth First Search, we explore all the nodes swap data which we want to swap and it takes less
aggressively to one path and then backtrack to the time. So, answer is option 'b'
node. Hence, it is equivalent to the pre-order 58. (a); The maximum number of comparison is number
traversal of a Binary Tree. of items ´ radix ´ number of digits i.e., 7 x 10 x 4 =
36. (a); The Depth First Search explores every node once 280.
and every edge once (in worst case), so it’s time 59. (b)
complexity is O(V + E). 60. (c)
37. (a); The Depth First Search is implemented using
recursion. So, stack can be used as data structure to
implement depth first search.

You might also like