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

Multiple choice
  1. The partition method returns the position of pivot element as it should be in the final sorted array.

  2. The average running time of quicksort is O(nlogn).

  3. Quicksort is faster than insertion sort and bubble sort.

  4. Best case running time of quicksort is O(nlogn).

  5. Worst case running time of quicksort is O(nlogn).

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

This is incorrect, the worst case running time of quicksort is quadratic.

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

  2. right[y] and left[y] respectively

  3. left[x] and right[x] respectively

  4. left[y] and right[y] respectively

  5. left[x] and left[y] respectively

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

This is correct,  since y is the parent node to null value, this will designate the new key to correct place.