Data Structures and Algorithms Fundamentals

Comprehensive quiz covering arrays, trees, graphs, hashing, complexity analysis, and searching algorithms

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

If n is even, and assuming that all A[i] are distinct, what what will be the result of the execution of the code given below:
for (i = 0; i < n; i++)
A[i] = A[n+1-i]?

  1. It results in 2 copies of each value data.
  2. The values remain unchanged.
  3. The array reverses.
  4. None of the above.
Question 2 Multiple Choice (Single Answer)

In a binary tree, an edge is the one which joins two nodes of two adjacent levels. Maximum possible edges of a tree with height h is

  1. h – 1
  2. h
  3. 2h
  4. none of the above
Question 3 Multiple Choice (Single Answer)

A set of values (23, 18, 29, 28, 39, 13, 16, 42, 17) are stored in an array having 11 locations (array indexes starts from 0) using quadratic probing and primary hashing function of key modulus number of locations is used. Possible locations of 17 and 29 are:

  1. 1, 8
  2. 4, 8
  3. 2, 8
  4. 3, 9
Question 4 Multiple Choice (Single Answer)

The least integer k such that (n) = (n+ 5 log n) / (n+ 1) is O(nk)

  1. 1
  2. 0
  3. – 1
  4. 3
Question 5 Multiple Choice (Single Answer)

Which of the following is not a limitation of binary search algorithm?

  1. Must use a sorted array
  2. Requirement of sorted array is expensive when a lot of insertion and deletions are needed
  3. There must be a mechanism to access middle element directly
  4. Binary search algorithm is not efficient when the data elements are more than 1000
Question 6 Multiple Choice (Single Answer)

Which of the following data structure stores the homogeneous data elements?

  1. Arrays
  2. Records
  3. Pointers
  4. None of the above
Question 7 Multiple Choice (Single Answer)

A graph’s adjacency matrix is as follows. Then the graph
            0100
            0010
            0001
            1000 is: 

  1. directed
  2. all nodes are a cycle
  3. one connected component
  4. all of the above
Question 8 Multiple Choice (Single Answer)

A 2 - 3 tree is a type of

  1. binary search tree
  2. search tree
  3. binary tree
  4. AVL tree
Question 9 Multiple Choice (Single Answer)

The number of distinct strings of length 3 that can be obtained using a, a, b, b, c is

  1. 7
  2. 6
  3. 12
  4. 15
Question 10 Multiple Choice (Single Answer)

A graph has adjacency matrix of all 1’s then

  1. it is fully connected
  2. its path matrix is same is adjacency matrix
  3. contains cycles
  4. all of the above
Question 11 Multiple Choice (Single Answer)

A Binany Search Tree search complexity is log2N, where N is the number of elements that are maintained as Binany Search Tree. If we change number of childs of the nodes to c instead of 2 in Binany Search Tree, then search complexity becomes

  1. (log2N)/c
  2. log2(N/c)
  3. logcN
  4. none of the above
Question 12 Multiple Choice (Single Answer)

Number of data items in a leaf node of a 2-3 tree is:

  1. 1
  2. 1 or 2
  3. 2
  4. 2 or 3
Question 13 Multiple Choice (Single Answer)

The indirect change of the values of a variable in one module by another module is called

  1. internal change
  2. inter-module change
  3. side effect
  4. side-module update
Question 14 Multiple Choice (Single Answer)

Find the correct statement

  1. In an undirected graph with positive edge weights, the shortest edge in the graph always belongs to any tree of shortest paths, provided the edge weights are distinct.
  2. To find the longest path between 2 given vertices in a graph G with positive weights, we can change the weight of every edge e from w(e) to k – w(e), where k is a value larger than any edge weight in G, and then find the shortest path in the resultant graph.
  3. If T is a tree of shortest paths from vertex s in a graph G, then T is also a tree of shortest paths from vertex s in a graph G’ obtained by increasing the weight of every edge by same value C.
  4. None of the above
Question 15 Multiple Choice (Single Answer)

What is the order of growth of the running time of an algorithm, if its running time is:
T(n) = [n(n log n + n2 + 3) + log(0.5n)] / n2 + 3.14

  1. 3.14n
  2. 3.14n
  3. n
  4. none of the above
Question 16 Multiple Choice (Single Answer)

The worst case behavior of linear search algorithm is seen when

  1. item is somewhere in the middle of the array
  2. item is not in the array at all
  3. item is the last element in the array
  4. item is the last element in the array or is not there at all
Question 17 Multiple Choice (Single Answer)

_______ is a technique that determines the solution by systematically searching the solution space for the given problem.

  1. Dynamic
  2. Backtracking
  3. Greedy
  4. None of the above
Question 18 Multiple Choice (Single Answer)

In a heap, element with the greatest key is always in the ___________ node.

  1. leaf
  2. root
  3. first node of left sub tree
  4. first node of right sub tree
Question 19 Multiple Choice (Single Answer)

Possible number of spanning trees with 4 vertexes are:

  1. 4
  2. 1
  3. 16
  4. None of the above
Question 20 Multiple Choice (Single Answer)

We have a chocolate of rectangular size with mxn rectangular pieces. We need to divide into pieces along the grooves. You are not allowed to split two or more stacked pieces at a time. The approach which divides into individual pieces has

  1. best case complexity
  2. worse case complexity
  3. average complexity
  4. any trail needs same number of splits
Question 21 Multiple Choice (Single Answer)

What is the worst case big-oh (asymptotic) cost of searching an element in a Binany Search Tree of depth d?

  1. O(logn)
  2. O(d)
  3. O(2d)
  4. None of the above
Question 22 Multiple Choice (Single Answer)

Time complexity of finding middle node of a single linked list is:

  1. O(1)
  2. O(log(n))
  3. O(n)
  4. O(n/2)
Question 23 Multiple Choice (Single Answer)

Given two arrays of numbers a1,..........., an and b1,............, bn where each number is 0 or 1, the fastest algorithm to find the largest span (i, j ) such that ai + ai+1 + .........+ aj = bi + bi + 1 +...........+ bj is:

  1. O(n2)
  2. O(n3)
  3. O(nlogn)
  4. O(2n)
Question 24 Multiple Choice (Single Answer)

Assume we have coins of denomination 1, 5, 10, 21 and 25 paisa, then the minimum and maximum number of coins needed to make 63 paisa is

  1. 5, 3
  2. 7, 3
  3. 6, 3
  4. None of these
Question 25 Multiple Choice (Single Answer)

Number of data items in a leaf node of a 2 - 3 tree are:

  1. 1
  2. 1 or 2
  3. 2
  4. 2 or 3