TechDataStructuresSamplePaper (50questions)
TechDataStructuresSamplePaper (50questions)
5. Which traversal prints the data in sorted order in Binary search tree ?
(1) Postorder traversal
(2) Preorder Traversal
(3) Inorder Traversal
(4) None of above.
15. The advantage of adjacency list representation over adjacency matrix in graph representation?
(1) Adding a vertex in adjacency list representation is much easier tha adjacency matrix
(2) DFS and BSF take much lesser time adjacency list representation.
(3) Space is saved for sparse graphs in adjacency list representation,
(4) All of the above
16. Sum of the degrees of all vertices with V vertices and E edges in undirected graph is
(1) 2E
(2) V+E
(3) 2V
(4) V
17. Using Bubble Sort, how many interchanges required to sort an int array containing "15, 10, 26,
12, 14" in ascending order :
(1) 2
(2) 4
(3) 5
(4) 6
18. A linear list in which insertion can only happen from end of the list and deletion can only happen
from the very start of the list, is called ?
(1) queue
(2) stack
(3) tree
(4) linked list
19. A linear list in which insertion and deletion can only happen from very end of the list, is called ?
(1) queue
(2) stack
(3) tree
(4) linked list
23. Which data structure can be used to check whether parenthesis are balanced or not
(1) tree
(2) queue
(3) array
(4) stack
(2) queue
(3) list
(4) tree
30. Which traversal algorithm gives the sorted order in binary search tree?
(1) level order
(2) pre order
(3) post order
(4) in order
32. An input restricted dequeue is a linear list in which items may be inserted at one end but
removed from either end. Such a data structure can be operated
(1) neither as a queue nor as a stack
(2) as a queue but not as a stack
(3) as a stack but not as a queue
(4) both as a queue and as a stack
33. Which of the following linked lists cannot contain NULL links?
(1) Single linked list
(2) Linear doubly linked list
(3) Circular linked list
(4) None of the above
35. The optimal way of calculating longest common subsequence in string has time complexity :
(1) O(n^3)
(2) O(n)
(3) O(n^2)
(4) None of the above
36. Let us suppose there are two strings s1 and s2 and operations :1. Insert 2. Remove 3.Replace
can be performed on s1. Calculate the number of operations that are needed to convert s1 into s2
of length m and n respectively
(1) O(m)
(2) O(n)
(3) O(m*n)
(4) O(m^2*n)
38. Time complexity for finding intersection point in two linked lists of length n1 and n2 is :
(1) O(n1+n2)
(2) O(n1 + n2)log(n1+n2)
(3) O(n1^2 + n2^2)
(4) None of the above
39. Time complexity for finding k largest elements in array of length n(optimally ) is :
(1) O(n + klogk)
(2) O(k + nlogk)
(3) O(k + (n-k)logk)
(4) None of the above
42. Time complexity of finding majority element (element appearing maximum number of times ) in
an array of length n is :
(1) O(n ^ 2)
(2) O(n)
(3) O(n ^ 3)
(4) None of the above
43. The space complexity(most efficient) for finding maximum product subarray in an array of
length n is :
(1) O(n)
(2) O(1)
(3) O(logn)
(4) None of the above
44. Which data types are used only for positive values in data structure?
(1) Signed
(2) Arrays
(3) Unsigned
(4) Boolean
46. What is the minimum number of nodes that a binary tree can have?
(1) 0
(2) 1
(3) 2
(4) 3
(3) queues
(4) trees
1. (2) O(1)
2. (2) abstract data type
3. (2) Data Structure
4. (2) Preorder Traversal
5. (3) Inorder Traversal
6. (2) greater than or equal to the data of elements in left subtree .
7. (3) Root element is lesser than its child elements
8. (1) -*wx+yz
9. (1) MAX( Height of left Subtree, Height of right subtree)+1
10. (2) Time and Space complexity
11. (2) false
12. (2) Stack
13. (3) O(n^2)
14. (2) Maximum sum Subarray in an array
15. (4) All of the above
16. (1) 2E
17. (3) 5
18. (1) queue
19. (2) stack
20. (2) queue
21. (4) binary search tree
22. (3) insert the element exactly in the middle of the linked list
23. (4) stack
24. (4) stack
25. (2) queue
26. (1) 2
27. (2) max heap
28. (2) 1
29. (1) stack
30. (4) in order
31. (2) CPU sheduling and disk sheduling
32. (4) both as a queue and as a stack
33. (3) Circular linked list
34. (3) Both A and B
35. (3) O(n^2)
36. (3) O(m*n)
37. (2) Quick sort
38. (1) O(n1+n2)
39. (3) O(k + (n-k)logk)
40. (1) LIFO
41. (2) FIFO
42. (2) O(n)
43. (2) O(1)
44. (3) Unsigned
45. (2) `-128 to +127`
46. (1) 0
47. (4) LIFO
48. (4) Double Ended Queue
49. (1) Head
50. (4) trees