# Data Structures Test 2016 – Upwork Test Answers

Till 27 February 2016, this Upwork Data Structures Test attended by 10,588 freelancers and total 4,278 freelancers qualified it. Please Try to review each questions and answers properly. Take your time. Maybe you can have **Top ****Result** in Upwork Data Structures Test.

Do you need prove? watch this video.

### Upwork Data Structures Test 2016

99 Answered Test Questions:

1. Which graph traversal algorithm uses a queue to keep track of the vertices which need to be processed?

Answers:

a. Breadth-first search

a. Depth-first search

2. A simple graph with n vertices and k components can have at the most _______.

Answers:

a. n edges

a. n-k edges

a. (n-k)(n-k-1)/2 edges

a. (n-k)(n-k+1)/2 edges

3. What is the minimum number of edges which must be removed from a complete bipartite graph of six nodes K(6) so that the remaining graph is a planar?

Answers:

a. 2

a. 3

a. 4

a. 6

4. Which feature of heaps allows them to be efficiently implemented using a partially filled array?

Answers:

a. Heaps are binary search trees

a. Heaps are complete binary trees

a. Heaps are full binary trees

a. Heaps contain only integer data

5. What happens if you make a recursive call without making the problem smaller?

Answers:

a. The operating system detects the infinite recursion because of the “repeated state”

a. The program keeps running until you press Ctrl-C

a. The results are non-deterministic

a. The run-time stack overflows, halting the program

6. Tree algorithms typically run in time O(d) . What is d?

Answers:

a. The depth of the tree

a. The number of divisions at each level

a. The number of nodes in the tree

a. The total number of entries in all the nodes of the tree

7. Here is a code for an integer variable n

while (n > 0)

{

n = n/10; // Use integer division

}

What is the worst case scenario analysis for the above loop?

Answers:

a. O(1)

a. O(log n)

a. O(n)

a. O(n2)

8. Suppose we have a circular array implementation of a queue, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the push member function place the new entry in the array?

Answers:

a. data[1]

a. data[2]

a. data[11]

a. data[12]

9. Which of the following sorting algorithms yield approximately the same worst-case and average-case running time behavior in O(n*log(n))?

Answers:

a. Bubble sort and selection sort

a. Heap sort and merge sort

a. Quick sort and radix sort

a. Tree sort and Median-of-3 quicksort

10. The operation for adding an entry to a stack is traditionally called ________.

Answers:

a. add

a. append

a. insert

a. push

11. For a complete binary tree with depth d, the total number of nodes is:

Answers:

a. 2d+1

a. 2d

a. 2d-1

a. 2d2

12. Which of the following is false?

Answers:

a. A binary search begins with the middle element in the array

a. A binary search continues halving the array either until a match is found or until there are no more elements to search

a. If the search argument is greater than the value located in the middle of the binary, the binary search continues in the lower half of the array

13. Which of the following applications may use a stack?

Answers:

a. A parentheses balancing program

a. Keeping track of local variables at run time

a. Syntax analyzer for a compiler

a. All of the above

14. What is the value of the post-fix expression 6 3 2 4 + – *?

Answers:

a. Something between -15 and -100

a. Something between -5 and -15

a. Something between 5 and 15

a. Something between 15 and 100

15. The minimum number of interchanges needed to convert the array 89,19,14,40,17,12,10,2,5,7,11,6,9,70 into a heap with the maximum element at the root is:

Answers:

a. 0

a. 1

a. 2

a. 3

16. Suppose T is a complete binary tree with 14 nodes. What would be the minimum possible depth of T?

Answers:

a. 0

a. 3

a. 4

a. 5

17. In which data structure do the insertion and deletion take place at the same end?

Answers:

a. Linked list

a. Tree

a. Stack

a. Linked list of stack

18. What is the formulae to find maximum number of nodes n in a perfect binary tree?

Answers:

a. 2h + 1 – 1

a. 2h + 1

a. 2h

a. 2h + 1 + 1

19. A chained hash table has an array size of 512. What is the maximum number of entries that can be placed in the table?

Answers:

a. 511

a. 512

a. 1024

a. There is no maximum limit

20. In which dynamically created linked list can the first node be recovered after moving to the second node?

Answers:

a. Simple linked list

a. Circular linked list

a. Doubly linked list

a. Both b and c

21. What is the best definition of a collision in a hash table?

Answers:

a. Two entries are identical except for their keys

a. Two entries with different data have exactly the same key

a. Two entries with different keys have exactly the same hash value

a. Two entries with exactly the same key have different hash values

22. What is the pre-order traversal equivalent of the following algebraic expression?

[a+(b-c)]*[(d-e)/(f+g-h)]

Answers:

a. abc-+de-fg+h-/*

a. *+a-bc/-de-+fgh

a. a+*b-/c-d-e+fgh

a. *+a-bc-/d+e-fgh

23. A sparse matrix can be a lower-triangular matrix when____.

Answers:

a. all the non-zero elements lie only on the leading diagonal

a. all the non-zero elements lie above the leading diagonal

a. all the non-zero elements lie below the leading diagonal

a. None of the above

24. A graph in which all nodes are of an equal degree is known as:

Answers:

a. Multigraph

a. Non – regular graph

a. Regular graph

a. Complete graph

25. What is the maximum number of statements that may be recursive calls in a single function declaration?

Answers:

a. 1

a. 2

a. n (n is the argument)

a. There is no fixed maximum

26. Which additional requirement is placed on an array so that binary search may be used to locate an entry?

Answers:

a. The array elements must form a heap

a. The array must have at least 2 entries

a. The array must be sorted

a. The array’s size must be a power of two

27. What is the worst-case scenario for heapsort to sort an array of n elements?

Answers:

a. O(log n)

a. O(n)

a. O(n log n)

a. O(n2)

28. The recurrence relation T(n)=mT(n/2)+an2 is satisfied by___

Answers:

a. T(n)=O(nm)

a. T(n)=O(m*log(m))

a. T(n)=O(n*log(m))

a. T(n)=O(m*log(n))

29. If ‘data’ is a circular array of CAPACITY elements and ‘last’ is an index in that array, what is the formula for the index after ‘last’?

Answers:

a. (last % 1) + CAPACITY

a. last % (1 + CAPACITY)

a. (last + 1) % CAPACITY

a. last + (1 % CAPACITY)

30. Consider the node of a complete binary tree whose value is stored in data[i] for an array implementation. If this node has a right child, where will the right child’s value be stored (the array’s first index is 0)?

Answers:

a. data[i+1]

a. data[i+2]

a. data[2*i + 1]

a. data[2*i + 2]

31. In a complete binary tree, the parent of any node k can be determined by ________.

Answers:

a. 2k

a. 2k+1

a. K/2

a. 2K-1

32. Consider a linked list of n elements which is pointed by an external pointer. What is the time taken to delete the element which is a successor of the pointed element by a given pointer?

Answers:

a. O(1)

a. O(log2n)

a. O(n)

a. O(n*log2n)

33. Suppose X is a B-tree leaf containing 41 entries and has at least one sibling. Which of the statements would be true in this case?

Answers:

a. Any sibling of X is also a leaf

a. Any sibling of X contains at least 41 entries

a. The parent of X has exactly 42 entries

a. X has at least 41 siblings

34. In a complete binary tree of n nodes, how far are the most distant two nodes? Assume each in the path counts 1. Assume log(n) is log base 2.

Answers:

a. about log(n)

a. about 2*log(n)

a. about 3*log(n)

a. about 4*log(n)

35. In a graph G, F is a spanning forest of G if

(i)F is a subgraph of G containing all the nodes of G

(ii)F is an order forest containing trees T1,T2,…Tn

(iii)Ti contains all the nodes that are reachable in G from the root Ti and are contained in Tj for some j<i..

Which of the above conditions is/are true?

Answers:

a. (i),(ii)

a. (ii),(iii)

a. (i),(iii)

a. (i),(ii) and (iii)

36. Which information is not saved in the activation record when a function call is executed?

Answers:

a. Current depth of recursion

a. Formal parameters

a. Location where the function should return when done

a. Local variables

37. The linked list implementation of sparse matrices is superior to the generalized dope vector method because it is __________.

Answers:

a. conceptually easier and completely dynamic

a. efficient if the sparse matrix is a band matrix

a. efficient in accessing an entry

a. all of these

38. Which situation occurs frequently if the selected hash function is poor?

Answers:

a. Overflow

a. Underflow

a. Collision

a. None of the above

39. The post-order traversal of a binary tree starts with:

Answers:

a. Post-order traversal of the left sub tree

a. Post-order traversal of the right sub tree

a. Post-order traversal of the root

a. Post-order traversal of the lowest node

40. One difference between a queue and a stack is:

Answers:

a. Queues require dynamic memory but stacks do not

a. Stacks require dynamic memory but queues do not

a. Queues use two ends of the structure but stacks use only one

a. Stacks use two ends of the structure but queues use only one

41. What is the minimum number of nodes in a full binary tree with depth 3?

Answers:

a. 4

a. 8

a. 11

a. 15

42. Using which traversal in a sorted binary insertion tree can a sorted array of numbers be obtained?

Answers:

a. Pre-order traversal

a. Post-order traversal

a. In order traversal

a. Top-down traversal

43. Where does the push member function place the new entry on the linked list in the linked list implementation of a queue?

Answers:

a. At the head

a. At the tail

a. After all other entries that are greater than the new entry

a. After all other entries that are smaller than the new entry

44. Which term is used to describe an O(n) algorithm?

Answers:

a. Constant

a. Linear

a. Logarithmic

a. Quadratic

45. What is the minimum number of nodes in a complete binary tree with depth 3?

Answers:

a. 4

a. 8

a. 11

a. 15

46. What is true of the complete bipartite graphs K(3,3) and K(2,4)?

Answers:

a. Both are planar

a. Neither is a planar

a. Both are isomorphic

a. None of these

47. If X is the adjacency matrix of a graph G with no self loops, the entries along the principle diagonal of X are ______.

Answers:

a. all zeros

a. all ones

a. both zeros and ones

a. different

48. Consider a linked list implementation of a queue with two pointers: front and rear. The time needed to insert element in a queue of length n is:

Answers:

a. O(1)

a. O(log2n)

a. O(n)

a. O(n*log2n)

49. What is the worst-case scenario for mergesort to sort an array of n elements?

Answers:

a. O(log n)

a. O(n)

a. O(n log n)

a. O(n2)

50. Consider a hashing function that resolves collision by quadratic probing. Assume that the address space is indexed from 1 to 8. If a collision occurs at position 4, the location which will never be probed is:

Answers:

a. 4

a. 5

a. 8

a. 2

51. In which data structure is the concept of rotation used?

Answers:

a. Binary search tree

a. Circular queue

a. AVL tree

a. Circular linked list

52. You have implemented a queue with a circular array keeping track of the first, the last, and the count (the number of items in the array). Suppose the first is zero, and the last is CAPACITY-1, what can you say about the count?

Answers:

a. The count must be zero

a. The count must be CAPACITY

a. The count can be zero or CAPACITY, but no other value can occur

a. None of the above

53. A procedure that calls itself in a program is called _______.

Answers:

a. Repeat

a. Loop

a. Recursion

a. Tree

54. State whether True or False.

For all possible inputs, a linear algorithm to solve a problem must perform faster than a quadratic algorithm to solve the same problem.

Answers:

a. True

a. False

55. If a max heap is implemented using a partially filled array called data, and the array contains n elements (n > 0), where is the entry with the greatest value?

Answers:

a. data[0]

a. data[n-1]

a. data[n]

a. data[2*n + 1]

56. What is the worst-case scenario for quicksort to sort an array of n elements?

Answers:

a. O(log n)

a. O(n)

a. O(n log n)

a. O(n2)

57. Which of the following lines of the code will delete two successive nodes of a single linked linear list(with more than two nodes)? Here ‘LINK[X]’ denotes the address field of node X.

Answers:

a. LINK[X]:=LINK[LINK[X]]

a. X:=LINK[LINK[X]]

a. LINK[LINK[X]]:=X

a. LINK[X]:=LINK[LINK[LINK[X]]]

58. A non- planar graph with the minimum number of vertices has:

Answers:

a. 10 edges, 5 vertices

a. 9 edges, 6 vertices

a. 6 edges, 4 vertices

a. 9 edges, 5 vertices

59. A circuit which is a connected graph and which includes every vertex of the graph is known as_____.

Answers:

a. Euler

a. Unicursal

a. Hamiltonian

a. Clique

60. A one dimensional array A has indices 1…75. Each element is a string and takes up three memory words. The array is stored starting at location 1120 decimal. The starting address of A[49] is:

Answers:

a. 1267

a. 1164

a. 1264

a. 1169

61. A simple graph in which there exists an edge between every pair of vertices is called a/an _________.

Answers:

a. incomplete graph

a. complete graph

a. Euler graph

a. planner graph

62. Let A be a sorted array of n=10 elements. Assume that only one comparison is required to determine whether the target is equal to, less than, or greater than A[i]. Which of the following denotes the average successful time of finding an arbitrary element x in A using the binary search?

Answers:

a. 1.6

a. 2.9

a. 4.2

a. 5.5

63. Which operations require linear time for their worst-case behavior in the linked-list version of a queue?

Answers:

a. front

a. push

a. empty

a. None of these operations require linear time

64. Which of the following statements about binary trees is false?

Answers:

a. Every Node must have at least two children

a. Every non-empty tree has exactly one root node

a. Every node has at the most two children

a. None of the above

65. How many real links are required for a sparse matrix having 10 rows, 10 columns and 15 non-zero elements? (Pick the nearest answer)

Answers:

a. 15

a. 20

a. 50

a. 100

66. In a graph G having the cut set matrix C(G) and an incidence matrix A(G), the rank of C(G) would be____

Answers:

a. The same as that of A(G)

a. More than that of A(G)

a. Less than that of A(G)

a. Independent of the rank of A(G)

67. Which of the operations is simpler in the doubly linked list than it is in the simple linked list?

Answers:

a. Insertion

a. Deletion

a. Both a and b

a. None of the above

68. Which of the following formulae in big-Oh notation best represents the expression n2+35n+6?

Answers:

a. O(n3)

a. O(n2)

a. O(n)

a. O(42)

69. The operation for removing an entry from a stack is traditionally called _______.

Answers:

a. delete

a. peek

a. pop

a. remove

70. Which queue allows insertion and deletion at both ends?

Answers:

a. Simple queue

a. Circular queue

a. Dequeue

a. Special queue

71. What kind of initialization needs to be done for a chained hash table?

Answers:

a. None

a. The key at each array location must be initialized

a. The head pointer of each chain must be set to NULL

a. Both B and C must be carried out

72. The number of nodes in the largest maximal independent set of the complete bipartite graph K(4,2) is_____ .

Answers:

a. 2

a. 3

a. 4

a. 6

73. Which of the following techniques is used to resolve collision in hashing?

Answers:

a. Separate chaining

a. Open addressing

a. Linear probing

a. All of the above

74. You have implemented a queue with a linked list keeping track of a front pointer and a rear pointer. Which of these pointers will you change during an insertion into a NONEMPTY queue?

Answers:

a. Neither of them changes

a. Only front_ptr changes

a. Only rear_ptr changes

a. Both change

75. Which of the following operations is performed more efficiently by the doubly linked list than by the linear linked list?

Answers:

a. Deleting a node the location of which is given

a. Searching an unsorted list for a given item

a. Inserting a node after the node with a given location

a. Traversing the list to process each node

76. Four characters are placed in a queue in the following order: D, C, B, and A. If they are removed one at a time, what will be the order of their removal?

Answers:

a. ABCD

a. ABDC

a. DCAB

a. DCBA

77. What is the meaning of the statement: “Entries in a stack are ‘ordered'”?

Answers:

a. A collection of stacks can be sorted

a. Stack entries may be compared with the ‘<‘ operation

a. The entries must be stored in a linked list

a. There is a first entry, a second entry, and so on

78. A given connected graph G is a Euler graph if and only if all vertices of G are of ______.

Answers:

a. the same degree

a. even degrees

a. odd degrees

a. different degrees

79. Which of the following data structures has a balanced condition?

Answers:

a. AVL Tree

a. Doubly Linked List

a. Double Ended Queue

a. Stack

80. A matrix is called sparse when______

Answers:

a. most of its elements are non-zero

a. most of its elements are zero

a. all of its elements are non-zero

a. None of the above

81. Which of the following operations in the simple linked list will modify the beginning of the linked list?

Answers:

a. Deletion of the first node

a. Insertion after the last node

a. Insertion after the first node

a. None of the above

82. You have implemented a queue with a circular array keeping track of the first item, the last item, and the count (the number of items in the array). Suppose the address of the first is zero, and that of the last is CAPACITY-1, what can you say about the count?

Answers:

a. The count must be zero

a. The count must be CAPACITY

a. The count can be zero or CAPACITY, but no other value can occur

a. None of the above

83. What is the worst-case scenario for the binary search for finding a single item in an array?

Answers:

a. Constant time

a. Logarithmic time

a. Linear time

a. Quadratic time

84. A binary tree, all the levels of which except possibly the last have the maximum number of nodes and all the nodes at the last level appear as far left as possible, is known as:

Answers:

a. Full binary tree

a. 2-Tree

a. Threaded tree

a. Complete binary tree

85. What is the pre-order traversal equivalent of the following algebraic expression?

[a+(b-c)]*[(d-e)/(f+(g-h))]

Answers:

a. abc-+de-fg+h-/*

a. *+a-bc/-de+f-gh

a. a+*b-/c-d-e+fgh

a. *+a-bc-/d+e-fgh

86. In the linked representation of a sparse matrix, the head node for a column list stores_____

Answers:

a. a pointer to the next column head node

a. a pointer to the first node in the column list

a. column number

a. All of the above

87. The hashing function which dynamically adapts to changes in the table being accessed is called ________.

Answers:

a. Real

a. Linear

a. Partial

a. Virtual

88. What will happen if in data structure a pop operation on the stack causes the stack pointer to move past the origin of the stack?

Answers:

a. Overflow

a. Underflow

a. Null

a. Garbage collection

89. If h is the depth of the tree, which formula will be used to find the maximum number of nodes n in a perfect binary tree?

Answers:

a. 2h + 1 – 1

a. 2h + 1

a. 2h

a. 2h + 1 + 1

90. What is the minimum number of edges and vertices possible in a non- planar graph?

Answers:

a. 10 edges, 5 vertices

a. 9 edges, 6 vertices

a. 6 edges, 4 vertices

a. 9 edges, 5 vertices

91. Which of the following is the worst-case scenario for operations on heaps?

Answers:

a. Neither insertion nor removal is better than linear

a. Insertion is better than linear, but removal is not

a. Removal is better than linear, but insertion is not

a. Both insertion and removal are better than linear

92. Which of these are standard operations of Stack Data Structure?

Answers:

a. Push, delete

a. Insert, pop

a. Put, extract

a. Push, pop

93. Suppose we have a circular array implementation of a queue, with ten items in the queue stored at data[2] through data[11]. The CAPACITY is 42. Where does the enqueue member function place the new entry in the array?

Answers:

a. data[1]

a. data[2]

a. data[11]

a. data[12]

94. A binary search tree is generated by inserting the following integers in the order: 50,15,62,5,20,58,91,3,8,37,60,24. How many nodes are in the left and right subtrees, respectively?

Answers:

a. (4,7)

a. (7,4)

a. (8,3)

a. (3,8)

95. What is the worst-case scenario for the binary search for finding a single item in an sorted array?

Answers:

a. Constant time

a. Logarithmic time

a. Linear time

a. Quadratic time

96. What is the maximum depth of recursive calls a function may make?

Answers:

a. 1

a. 2

a. n (where n is the argument)

a. There is no fixed maximum

97. Consider this binary search tree.

Which will be the new root if you remove the root and replace it with something from the left subtree?

Answers:

a. 1

a. 2

a. 4

a. 5

98. The number of distinct simple graphs with up to three nodes is _______.

Answers:

a. 15

a. 10

a. 7

a. 9

99. In a selection sort algorithm, the number of passes required to perform the sort are ______.

Answers:

a. N

a. N-1

a. N-2

a. N^2

4 NOT Answered Yet Test Questions:

(hold on, will be updated soon)

100. You have implemented a queue with a linked list keeping track of a front pointer and a rear pointer. Which of these pointers will you change during an insertion in the middle of a NONEMPTY queue?

Answers:

a. Neither of them changes

a. Only front_ptr changes

a. Only rear_ptr changes

a. Both change

101. Which formula is the best approximation for the depth of a heap with n nodes?

Answers:

a. log (base 2) of n

a. The number of digits in n (base 10)

a. The square root of n

a. n

102. What do we call a binary tree in which all the levels, except possibly the last level, have the maximum number of nodes, and in which all the nodes at the last level appear as far left as possible?

Answers:

a. Full binary tree

a. 2-Tree

a. Threaded tree

a. Complete binary tree

103. Which of the following operations is more expensive in the dynamically created linked list than it is in the conventional array?

Answers:

a. Finding Kth element

a. Insertion

a. Deletion

a. Traversing