Quiznetik

Data Structures (DS) | Set 1

1. Which of these best describes an array?

Correct : B. Container of objects of similar types

2. How do you initialize an array in C?

Correct : C. int arr[3] = {1,2,3};

3. How do you instantiate an array in Java?

Correct : C. int arr[] = new int[3];

4. Which of the following is a correct way to declare a multidimensional array in Java?

Correct : C. int[][]arr;

5. When does the ArrayIndexOutOfBoundsException occur?

Correct : B. Run-time

6. Which of the following concepts make extensive use of arrays?

Correct : D. Spatial locality

7. What are the advantages of arrays?

Correct : D. Easier to store elements of same data type

8. What are the disadvantages of arrays?

Correct : B. There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size

9. Assuming int is of 4bytes, what is the size of int arr[15];?

Correct : D. 60

10. In general, the index of the first element in an array is

Correct : A. 0

11. Elements in an array are accessed

Correct : A. randomly

12. Which of the following is not a disadvantage to the usage of array?

Correct : D. Accessing elements at specified positions

13. What is the time complexity of inserting at the end in dynamic arrays?

Correct : D. Either O(1) or O(n)

14. What is the time complexity to count the number of elements in the linked list?

Correct : B. O(n)

15. What is the space complexity for deleting a linked list?

Correct : A. O(1)

16. Which of these is not an application of linked list?

Correct : D. Random Access of elements

17. Which of the following is false about a doubly linked list?

Correct : D. Implementing a doubly linked list is easier than singly linked list

18. What is the worst case time complexity of inserting a node in a doubly linked list?

Correct : C. O(n)

19. What differentiates a circular linked list from a normal linked list?

Correct : C. You may or may not have the ‘next’ pointer point to null in a circular linked list

20. What is the time complexity of searching for an element in a circular linked list?

Correct : A. O(n)

21. Which of the following application makes use of a circular linked list?

Correct : C. Allocating CPU to resources

22. Which of the following is false about a circular linked list?

Correct : B. Time complexity of inserting a new node at the head of the list is O(1)

23. Consider a small circular linked list. How to detect the presence of cycles in this list effectively?

Correct : B. Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer advancing by one node at a time

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

Correct : A. Linked list

25. In linked list each node contain minimum of two fields. One field is data field to store the data second field is?

Correct : C. Pointer to node

26. What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?

Correct : C. θ(n)

27. What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?

Correct : A. O(1)

28. What would be the asymptotic time complexity to find an element in the linked list?

Correct : B. O(n)

29. What would be the asymptotic time complexity to insert an element at the second position in the linked list?

Correct : A. O(1)

30. The concatenation of two list can performed in O(1) time. Which of the following variation of linked list can be used?

Correct : C. Circular doubly linked list

31. Which of the following c code is used to create new node?

Correct : A. ptr = (NODE*)malloc(sizeof(NODE));

32. Process of inserting an element in stack is called

Correct : B. Push

33. Process of removing an element from stack is called

Correct : D. Pop

34. In a stack, if a user tries to remove an element from empty stack it is called

Correct : A. Underflow

35. Pushing an element into stack already having five elements and stack size of 5, then stack becomes

Correct : A. Overflow

36. Entries in a stack are “ordered”. What is the meaning of this statement?

Correct : D. There is a Sequential entry that is one by one

37. Which of the following is not the application of stack?

Correct : D. Data Transfer between two asynchronous process

38. Consider the usual algorithm for determining whether a sequence of parentheses is balanced. Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order). The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

Correct : B. 2

39. What is the value of the postfix expression 6 3 2 4 + – *?

Correct : D. -18

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

Correct : C. AB + CD* E – *F *G /

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

Correct : A. Stack

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

Correct : B. Stack

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

Correct : D. Stack

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

Correct : B. AB*CD/+

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

Correct : D. Stack

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

Correct : C. -A/B*C^DE

47. What is the result of the following operation? Top (Push (S, X))

Correct : A. X

48. The prefix form of an infix expression (p + q) – (r * t) is?

Correct : C. – +pq * rt

49. Which data structure is used for implementing recursion?

Correct : B. Stack

50. When an operand is read, which of the following is done?

Correct : A. It is placed on to the output

51. What should be done when a left parenthesis ‘(‘ is encountered?

Correct : C. It is placed in the operator stack

52. Which of the following is an infix expression?

Correct : A. (a+b)*(c+d)

53. What is the time complexity of an infix to postfix conversion algorithm?

Correct : B. O(N)

54. Which of the following statement is incorrect with respect to infix to postfix conversion algorithm?

Correct : C. parenthesis are included in the output

55. In infix to postfix conversion algorithm, the operators are associated from?

Correct : B. left to right

56. 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 ?

Correct : A. Queue

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

Correct : C. Queue

58. A queue follows

Correct : A. FIFO (First In First Out) principle

59. Circular Queue is also known as

Correct : A. Ring Buffer

60. 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?

Correct : A. ABCD

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

Correct : C. Dequeue

62. A normal queue, if implemented using an array of size MAX_SIZE, gets full when

Correct : A. Rear = MAX_SIZE – 1

63. Queues serve major role in

Correct : C. Simulation of limited resource allocation

64. Which of the following is not the type of queue?

Correct : B. Single ended queue

65. With what data structure can a priority queue be implemented?

Correct : D. Tree

66. Which of the following is not an application of priority queue?

Correct : C. Undo operation in text editors

67. What is the time complexity to insert a node based on key in a priority queue?

Correct : C. O(n)

68. What is not a disadvantage of priority scheduling in operating systems?

Correct : C. Interrupt handling

69. Which of the following is not an advantage of priority queue?

Correct : D. Easy to delete elements in any case

70. What is the time complexity to insert a node based on position in a priority queue?

Correct : C. O(n)

71. What is a dequeue?

Correct : A. A queue with insert/delete defined for both front and rear ends of the queue

72. What are the applications of dequeue?

Correct : D. To avoid collision in hash tables

73. Which of the following properties is associated with a queue?

Correct : B. First In First Out

74. In a circular queue, how do you increment the rear end of the queue?

Correct : B. (rear+1) % CAPACITY

75. What is the term for inserting into a full queue known as?

Correct : A. overflow

76. What is the time complexity of enqueue operation?

Correct : D. O(1)

77. What is the need for a circular queue?

Correct : A. effective usage of memory

78. What is the space complexity of a linear queue having n elements?

Correct : A. O(n)

79. What is the maximum number of children that a binary tree node can have?

Correct : C. 2

80. The following given tree is an example for?

Correct : A. Binary tree

81. How many common operations are performed in a binary tree?

Correct : C. 3

82. What is the traversal strategy used in the binary tree?

Correct : B. breadth-first traversal

83. How many types of insertion are performed in a binary tree?

Correct : B. 2

84. What operation does the following diagram depict?

Correct : C. deleting a node with 0 or 1 child

85. How many bits would a succinct binary tree occupy?

Correct : B. 2n+O(n)

86. The average depth of a binary tree is given as?

Correct : D. O(log N)

87. How many orders of traversal are applicable to a binary tree (In General)? 3

Correct : D. 3

88. If binary trees are represented in arrays, what formula can be used to locate a left child, if the node has an index i?

Correct : A. 2i+1

89. Using what formula can a parent node be located in an array?

Correct : B. (i-1)/2

90. Which of the following properties are obeyed by all three tree – traversals?

Correct : A. Left subtrees are visited before right subtrees

91. For the tree below, write the pre-order traversal.

Correct : A. 2, 7, 2, 6, 5, 11, 5, 9, 4

92. For the tree below, write the post-order traversal.

Correct : C. 2, 5, 11, 6, 7, 4, 9, 5, 2

93. What is the time complexity of pre-order traversal in the iterative fashion?

Correct : B. O(n)

94. What is the space complexity of the post-order traversal in the recursive fashion? (d is the tree depth and n is the number of nodes)

Correct : D. O(d)

95. To obtain a prefix expression, which of the tree traversals is used?

Correct : B. Pre-order traversal

96. Consider the following data. The pre order traversal of a binary tree is A, B, E, C, D. The in order traversal of the same binary tree is B, E, A, D, C. The level order sequence for the binary tree is

Correct : B. A, B, C, D, E

97. What is the possible number of binary trees that can be created with 3 nodes, giving the sequence N, M, L when traversed in post-order.

Correct : C. 5

98. The post-order traversal of a binary tree is O P Q R S T. Then possible pre-order traversal will be

Correct : C. T Q O P S R

99. A binary search tree contains values 7, 8, 13, 26, 35, 40, 70, 75. Which one of the following is a valid post-order sequence of the tree provided the pre-order sequence as 35, 13, 7, 8, 26, 70, 40 and 75?

Correct : D. 8, 7, 26, 13, 40, 75, 70, 35

100. Which of the following pair’s traversals on a binary tree can build the tree uniquely?

Correct : B. post-order and in-order