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

  2. arrangement of objects

  3. iteration

  4. both (1) and (3)

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

Structured programming is built on three fundamental control structures: sequence (executing steps in order), selection (making decisions with if-then-else), and iteration (looping with while or for). These structures form the basis for writing organized, maintainable code without goto statements.

Multiple choice
  1. 2n

  2. 5n

  3. 7n/2

  4. log2n

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

A decision table with n conditions can create 2^n possible combinations of condition outcomes. Each combination becomes a rule (column) in the table. For example, 3 conditions yield 8 rules, 4 conditions yield 16 rules. This exponential growth makes decision tables complex for many conditions.

Multiple choice
  1. It enhances logical clarity and reduces code size.

  2. It makes debugging easier and reduces execution time.

  3. It reduces execution time.

  4. It makes software bug-free and easy to use.

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

Recursion enhances logical clarity by expressing complex problems in simpler, self-referential terms. It often reduces code size because the same logic is applied repeatedly without loops. However, recursion typically INCREASES execution time due to function call overhead and can make debugging harder due to stack complexity. Option A correctly captures the primary benefits.

Multiple choice
  1. A binary tree is the one in which the internal nodes have atmost two children.

  2. File system in unix OS make use of trees.

  3. In a complete binary tree, the number of internal nodes is 1 less than the number of leaves.

  4. In a binary tree, the number of internal nodes is greater than the number of leaves.

  5. A tree with n nodes can have a maximum height n -1.

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

This statement is incorrect.

Multiple choice
  1. A search operation in an ordered list will take C.

  2. An insert operation in an ordered list will take B.

  3. A search operation in an un ordered list will take B.

  4. An insert operation in an un ordered list will take A.

  5. 1 and 2 are correct.

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

This is correct. In an ordered list searching will take up O(log n) time using binary search

Multiple choice
  1. 1 and 5

  2. 2 and 5

  3. 3 and 4

  4. 2 and 4

  5. 1 and 4

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

This is correct, as in the given algorithm , first v node is visited and then child nodes, it is preorder traversal. So in the beginning of traversal root will be traversed

Multiple choice
  1. x = left[x] and x respectively

  2. x = k and x respectively

  3. x = right[x] and x respectively

  4. x = left[right[x]] and k respectively

  5. x != right[x] & x respectively

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

This is correct, as in the else part the condition which holds is if(x > k) then the next x should be left[x]. Again,  since at the end x only contains the node where the key is present, so x should be returned

Multiple choice
  1. finds the maximum key in the tree

  2. finds the minimum key in the tree

  3. finds the root key in the tree

  4. finds the rightmost leaf-key in the tree

  5. finds the maximum internal node in the tree

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

This is correct, as  the algorithm updates the x value to right[x], it is looking for the maximum key.

Multiple choice
  1. O(h)

  2. O(n)

  3. O(nh)

  4. O(n2)

  5. O(h2)

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

 This is correct, as the worst case will comprise of height n-1. So O(n) will be the running and is the specific answer.

Multiple choice
  1. finds the successor of key x in the tree

  2. finds the predecessor of key x in the tree

  3. finds the maximum key in the tree

  4. finds the minimum key in the tree

  5. none of the above

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

This is correct. If right[x] != null, then the minimum key in the right sub-tree will be the successor otherwise it will trace its way to the parent node which is greater than key value.