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. O(n2)

  2. O(nlogn)

  3. O(logn)

  4. O(n)

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

Quick sort's average case achieves O(n log n) when pivots consistently create roughly balanced partitions, dividing the problem size logarithmically.

Multiple choice
  1. O

  2. O(n)

  3. O(logn)

  4. None of these

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

Merge sort requires O(n) auxiliary space for the temporary arrays used during the merge phase of each recursive call, regardless of time complexity.

Multiple choice
  1. O(n2)

  2. O(nlogn)

  3. O(logn)

  4. O(n)

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

Merge sort always divides input in half and recursively merges, requiring n comparisons per level across log n levels, giving O(n log n) in all cases.

Multiple choice
  1. 0

  2. O(n)

  3. O(logn)

  4. None of these

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

Quick sort's worst-case space complexity is O(n) for recursive implementations when poor pivots create maximum recursion depth, causing stack frames proportional to input size. (Note: optimized implementations using tail recursion or iteration can achieve O(log n)).

Multiple choice
  1. O(n2)

  2. O(nlogn)

  3. O(logn)

  4. O(n)

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

Quick sort's worst case occurs when pivots consistently create maximally unbalanced partitions (sorted or reverse-sorted input with poor pivot choice), degrading to O(n²) time complexity.

Multiple choice
  1. O(n2)

  2. O(nlogn)

  3. O(logn)

  4. O(n)

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

Selection sort always performs n-1 passes with decreasing comparisons per pass, totaling approximately n²/2 comparisons regardless of input order, giving O(n²) in all cases.

Multiple choice
  1. 0

  2. O(n)

  3. O(logn)

  4. None of these

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

Merge sort requires O(n) auxiliary space in the worst case because it needs to merge subarrays by copying elements into temporary arrays. The divide-and-conquer approach creates new arrays during the merge phase.

Multiple choice
  1. Greedy

  2. Depth-first search

  3. Dyanamic programming

  4. Divide and conquer

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

Quick sort uses the divide and conquer paradigm by selecting a pivot element and partitioning the array around it. It then recursively sorts the sub-arrays on either side of the pivot.

Multiple choice
  1. Singly linked list

  2. Doubly linked list

  3. Circular doubly linked list

  4. Array implementation

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

A circular doubly linked list allows O(1) concatenation because you only need to update a few pointers: connect the tail of the first list to the head of the second, and vice versa. This works in constant time regardless of list size.