Computer Knowledge

Data Structures and Algorithms

1,518 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/2

  2. n-1

  3. 2n-1

  4. 2n

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

2 × (4) − 1 = 7 reductions $\Rightarrow$2n − 1 reductions are required. [Note: Unit production is given as A $\rightarrow$ a, it was typo] Above reductions are not in reverse of RMD but when they are reduced in bottom-up parsing, we will get same number of reductions.

Multiple choice
  1. $\Theta(1)$
  2. $\Theta(\sqrt{\log} n)$
  3. $\Theta(\frac{\log n}{\log \log n})$
  4. $\Theta(\log n)$
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

After constructing a max-heap in the heap sort, the time to extract maximum element and then heapifying the heap takes $\Theta$(log n) time by which we could say that $\Theta$ (log n) time is required to correctly place an element in sorted array. If $\Theta$ (logn) time is taken to sort using heap sort, then number of elements that can be sorted is constant which is $\Theta$ (1).

Multiple choice
  1. 2.4 ns

  2. 2.3 ns

  3. 1.8 ns

  4. 1.7 ns

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

Multiple choice
  1. 2.4 ns

  2. 2.3 ns

  3. 1.8 ns

  4. 1.7 ns

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

Multiple choice
  1. 0

  2. $\dfrac{1}{16}$
  3. $\dfrac{1}{8}$
  4. 16

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

Multiple choice
  1. A heap can be used but not a balanced binary search tree

  2. A balanced binary search tree can be used but not a heap

  3. Both balanced binary search tree and heap can be used

  4. Neither balanced binary search tree nor heap can be used

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

Both the tasks can be performed by both the data structures but heap is a data structure where to perform these function every element has to be checked so  O (n) complexity. But the balance binary search tree is efficient data structure since at every decision it selects one of its sub tree to no. of elements to be checked are reduced by a factor of / 1 2 every time. $\dfrac{n}{2!} = x$ x = log n

Multiple choice
  1. n(X + Y)

  2. 3Y + 2X

  3. n(X + Y) - X

  4. Y + 2X

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

Multiple choice
  1. the list is empty or has exactly one element

  2. the elements in the list are sorted in non-decreasing order of data value

  3. the elements in the list are sorted in non-increasing order of data value

  4. not all elements in the list have the same data value

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

Multiple choice
  1. only (i)

  2. only (ii)

  3. either (i) or (ii) but not both

  4. neither (i) nor (ii)

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