• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top 50 Data Structures MCQs with Answers

Question 41

Which of the following correctly declares an array?

  • int geeks[20];

  • int geeks;

  • geeks{20};

  • array geeks[20];

Question 42

A three dimensional array in ‘C++’ is declared as int A[x][y][z]. Consider that array elements are stored in row major order and indexing begins from 0. Here, the address of an item at the location A[p][q][r] can be computed as follows (where w is the word length of an integer):

  • &A[0][0][0] + w(y * z * q + z * p + r)

  • &A[0][0][0] + w(y * z * p + z*q + r)

  • &A[0][0][0] + w(x * y * p + z * q+ r)

  • &A[0][0][0] + w(x * y * q + z * p + r)

Question 43

Let A be a square matrix of size n x n. Consider the following program. What is the expected output? 

C = 100
for i = 1 to n do
for j = 1 to n do
{
Temp = A[i][j] + C
A[i][j] = A[j][i]
A[j][i] = Temp - C
}
for i = 1 to n do
for j = 1 to n do
Output(A[i][j]);
  • The matrix A itself

  • Transpose of matrix A

  • Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of A

  • None of the above

Question 44

A program P reads in 500 integers in the range [0..100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
 

  • An array of 50 numbers
     

  • An array of 100 numbers
     

  • An array of 500 numbers
     

  • A dynamically allocated array of 550 numbers
     

Question 45

Which of the following is FALSE about B/B+ tree
  • B/B+ trees grow upward while Binary Search Trees grow downward.
  • Time complexity of search operation in B/B+ tree is better than Red Black Trees in general.
  • Number of child pointers in a B/B+ tree node is always equals to number of keys in it plus one.
  • A B/B+ tree is defined by a term minimum degree. And minimum degree depends on hard disk block size, key and address sizes.

Question 46

The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?
  • 24
  • 25
  • 26
  • 27

Question 47

A B-Tree used as an index for a large database table has four levels including the root node. If a new key is inserted in this index, then the maximum number of nodes that could be newly created in the process are
  • 5
  • 4
  • 1
  • 2

Question 48

In a file which contains 1 million records and the order of the tree is 100, then what is the maximum number of nodes to be accessed if B+ tree index is used?

  • 5

  • 4

  • 3

  • 10

Question 49

B+ Trees are considered BALANCED because
  • the lengths of the paths from the root to all leaf nodes are all equal.
  • the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
  • the number of children of any two non-leaf sibling nodes differ by at most 1.
  • the number of records in any two leaf nodes differ by at most 1.

Question 50

Let G be the directed, weighted graph shown in below figure gra We are interested in the shortest paths from A. (a) Output the sequence of vertices identified by the Dijkstra’s algorithm for single source shortest path when the algorithm is started at node A. (b) Write down sequence of vertices in the shortest path from A to E. (c) What is the cost of the shortest path from A to E?

    There are 50 questions to complete.

    Last Updated :
    Take a part in the ongoing discussion