Computer Knowledge

Data Structures and Algorithms

1,256 Questions

Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.

Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity

Data Structures and Algorithms Questions

Multiple choice
  1. n + m $\le$ x < 2n and 2m $\le$ y $\le$ n + m
  2. n + m $\le$ x < 2n and 2m $\le$ y $\le$ 2n
  3. 2m $\le$ x < 2n and 2m $\le$ y $\le$ n + m
  4. 2m $\le$ x < 2n and 2m $\le$ y $\le$ 2n
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The order in which insert and delete operations are performed matters here. The best case: Insert and delete operations are performed alternatively. In every delete operation, 2 pop and 1 push operations are performed. So, total m+ n push (n push for insert() and m push for delete()) operations and 2m pop operations are performed. The worst case: First n elements are inserted and then m elements are deleted. In first delete operation, n + 1 pop operations and n push operation are performed. Other than first, in all delete operations, 1 pop operation is performed. So, total m + n pop operations and 2n push operations are performed (n push for insert() and n push for delete())

Multiple choice
  1. 8, −, −, −, −, −, 10

  2. 1, 8, 10, −, −, −, 3

  3. 1, −, −, −, −, −, 3

  4. 1, 10, 8, −, −, −, 3

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Multiple choice
  1. the number of nodes in the tree

  2. the number of internal nodes in the tree

  3. the number of leaf nodes in the tree

  4. the height of the tree

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Multiple choice
  1. The Array values are always sorted.

  2. The default value of numeric array elements is zero.

  3. Array elements can be of integer type only.

  4. The rank of an Array is the total number of elements it can contain.

  5. An array can be resized during the runtime.

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Since the default value of an int is 0, the default value of all the elements in a numeric array is 0.

Multiple choice
  1. 1 and 2 only

  2. 3 and 4 only

  3. 5 only

  4. 1, 2 and 5 only

  5. All of the above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The BitArray class stores a compact array of bit values. These value are boolean in nature storing 0 and 1. Elements in an BitArray are accessed using an integer index which starts from 0. Arraylist represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike array, you can add and remove items from a list at a specified position using an index.