Upwork Test Answers: Get all the correct answers of most recent and possible Upwork Tests A to Z (Updated on Jan, 2016)
Cover Letter Templates: These cover letter samples are not only for Upwork job, but also you will have some idea about your real life job
 
Freelance Profile Overviews: Different Profile samples and overviews of experts, advanced and intermediate level freelancers
For Newbie of Upwork: Upwork Help - How to apply for a job in Upwork with 10 most important articles about Upwork

A to Z View - All Upwork Test Answers

Upwork Data Structures Test Answer

Updated on 05 January - 2016

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

Answers: • Breadth-first search

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

Answers: • (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: • 6

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

Answers: • Heaps are complete binary trees

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

Answers: • The run-time stack overflows, halting the program

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

Answers: • The depth 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: • O(log n)

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: • 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: • Heap sort and merge sort

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

Answers: • push

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

Answers: • 2d+1

12. Which of the following is false?

Answers: • 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: • All of the above

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

Answers: • 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: • 3

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

Answers: • 4

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

Answers: • Stack

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

Answers: • 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: • 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: • Both b and c

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

Answers: • Two entries with different keys have exactly the same hash value

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

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

Answers: • *+a-bc/-de-+fgh

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

Answers: • all the non-zero elements lie below the leading diagonal

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

Answers: • Regular graph

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

Answers: • 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: • The array must be sorted

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

Answers: • O(n log n)

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

Answers: • 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: • (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: • data[2*i + 2]

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

Answers: • K/2

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: • O(1)

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: • Any sibling of X is also a leaf

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: • about 2*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: • (i),(ii)

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

Answers: • Current depth of recursion

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

Answers: • efficient if the sparse matrix is a band matrix

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

Answers: • Collision

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

Answers: • Post-order traversal of the left sub tree

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

Answers: • Queues use two ends of the structure but stacks use only one

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

Answers: • 15

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

Answers: • In order 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: • At the tail

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

Answers: • Linear

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

Answers: • 11

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

Answers: • 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: • all zeros

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: • O(1)

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

Answers: • O(n log n)

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: • 8

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

Answers: • AVL tree

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: • The count must be CAPACITY

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

Answers: • Recursion

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: • 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: • data[n-1]

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

Answers: • 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: • LINK[X]:=LINK[LINK[LINK[X]]]

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

Answers: • 9 edges, 6 vertices

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

Answers: • Hamiltonian

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: • 1264

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

Answers: • complete 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: • 2.9

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

Answers: • empty

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

Answers: • Every Node must have at least two children

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: • 15

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: • Less than that of A(G)

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

Answers: • Deletion

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

Answers: • O(n2)

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

Answers: • pop

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

Answers: • Circular queue

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

Answers: • The head pointer of each chain must be set to NULL

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

Answers: • 4

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

Answers: • 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: • Only rear_ptr changes

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

Answers: • Deleting a node the location of which is given

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: • DCBA

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

Answers: • Stack entries may be compared with the '<' operation

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

Answers: • even degrees

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

Answers: • AVL Tree

80. A matrix is called sparse when______

Answers: • most of its elements are zero

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

Answers: • 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: • The count must be CAPACITY

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

Answers: • Linear 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: • 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-bc/-de+f-gh

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

Answers: • column number

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

Answers: • 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: • Underflow

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: • 2h + 1

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

Answers: • 10 edges, 5 vertices

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

Answers: • Insertion is better than linear, but removal is not

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

Answers: • 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: • 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: • (7,4)

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

Answers: • Linear time

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

Answers: • 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: • 5

98. The number of distinct simple graphs with up to three nodes is _______.
Answers: • 7


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

Answers: • N-1