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. 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 a nested loop to find the minimum element, resulting in O(n^2) complexity regardless of the initial order of elements.

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

Bubble sort compares adjacent elements in nested loops, leading to O(n^2) in the worst case when the array is sorted in reverse order.

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 guarantees O(n log n) time complexity in all cases, including the worst case, because the splitting and merging steps are always balanced.

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

In the worst case, such as a reverse-sorted array, every element must be compared and shifted across all previously sorted elements, leading to O(n^2).

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 complexity is O(n^2), which occurs when the pivot selection consistently results in highly unbalanced partitions.

Multiple choice
  1. Fixed length storage structure

  2. Variable length storage with fixed maximum

  3. Linked list storage

  4. Array type storage

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

Linked lists are dynamic structures that allow for efficient insertion and deletion by simply updating pointers. Unlike arrays, they do not require shifting elements, making them ideal for frequent modifications.

Multiple choice
  1. depth first order

  2. breadth first order

  3. topological order

  4. linear order

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

Pre-order traversal (Root, Left, Right) is a form of depth-first search where the root is visited before its subtrees. DFS explores as deep as possible along each branch before backtracking.

Multiple choice
  1. Pre oder traversal

  2. Post order traversal

  3. In order traversal

  4. Top-down traversal

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

A binary search tree stores keys in sorted order relative to their nodes. An in-order traversal (Left, Root, Right) visits nodes in ascending sorted order, perfect for producing a sorted array.