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. 2

  2. 3

  3. 4

  4. 5

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

Multiple choice
  1. 46, 42, 34, 52, 23, 33

  2. 34, 42, 23, 52, 33, 46

  3. 46, 34, 42, 23, 52, 33

  4. 42, 46, 33, 23, 34, 52

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

Multiple choice
  1. The algorithm uses dynamic programming paradigm.

  2. The algorithm has a linear complexity and uses branch and bound paradigm.

  3. The algorithm has a non-linear polynomial complexity and uses branch and bound paradigm.

  4. The algorithm uses divide and conquer paradigm.

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

This algorithm uses dynamic programming because it solves the problem by breaking it into smaller subproblems (L_i depends on L_{i+1]) and stores the results. It builds the solution bottom-up from the base case L[n-1] = 1. The complexity is O(n) linear time. It does not use branch and bound (which prunes search trees) or divide and conquer (which recursively splits problems).

Multiple choice
  1. 0

  2. 1

  3. n!

  4. $\frac{1} {n+1} .^{2n}C_n$
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The number of distinct BSTs with n distinct keys is the nth Catalan number: C(n) = (1/(n+1)) * (2nCn) = (2n)!/((n+1)!n!). This is a fundamental result in combinatorics - the structure of a BST is determined solely by the relative ordering of elements. With n distinct elements and n nodes, there are exactly C(n) ways to build a BST.

Multiple choice
  1. 2

  2. 9

  3. 5

  4. 3

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

Load R1,a ; R1 $\leftarrow$M[a] Load R2,b ; R2 $\leftarrow$M[b] Sub R1,R ; R1 $\leftarrow$R1 – R2 Load R2 ,c ; R2 $\leftarrow$M[c] Load R3 ,d ; R3 $\leftarrow$Md] Add R2 , R3 ; R2 $\leftarrow$R2 R3 Load R3 ,e ; R3 $\leftarrow$M[e] Sub R3, R2 : R3$\leftarrow$R3 – R2 Add R1 ,R3 ; R1 $\leftarrow$R1 R3 Minimum 3 Registers are required.