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. A queue is defined as an ordered list.

  2. A queue can be implemented by the array.

  3. The element is deleted from the from end of the queue.

  4. A queue is a FIFO (First In First Out Data Structure).

  5. None of the above

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

Yes, all of the above are the true statements.

Multiple choice
  1. O(|E|log|V|)

  2. O(VlogE)

  3. O(EV)

  4. O(log V)

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

Kruskal's algorithm uses edge sorting and union-find. Sorting |E| edges takes O(|E| log |E|) ≈ O(|E| log |V|) since |E| ≤ |V|². Union-find operations are nearly O(1) with path compression and union by rank. The dominant cost is sorting, giving O(|E| log |V|). Adjacency list representation is standard.

Multiple choice
  1. O(|V|2)

  2. O(VlogE)

  3. O(EV)

  4. O(log V)

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

Prim's algorithm on an adjacency matrix requires scanning all vertices to find the minimum weight edge, taking O(|V|) per vertex. With |V| iterations, total is O(|V|²). With Fibonacci heap + adjacency list, it becomes O(|E| + |V| log |V|), but O(|V|²) is the standard answer for basic implementation.

Multiple choice
  1. O(|E|log|V|)

  2. O(VlogE)

  3. O(EV)

  4. O(log V)

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

Prim's algorithm using a binary heap performs O(|E|) extract-min and O(|V|) decrease-key operations, each costing O(log|V|). The dominant term is |E|log|V| because the number of edges is typically greater than vertices. Option B incorrectly writes V as base and E as exponent, while C and D are not the correct complexity for heap-based Prim's.

Multiple choice
  1. only similar data type

  2. any data type

  3. only two data types

  4. only 5 data types

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

Structures in C++ can contain members of different data types (int, float, char, etc.) unlike arrays which require similar types. This makes structs versatile for grouping related data.

Multiple choice
  1. analysis traversal operation

  2. traversal operation

  3. search operation

  4. linear search operation

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

Traversal is the process of systematically visiting each element in a data structure exactly once. This fundamental operation is essential for accessing, processing, or analyzing every element in an array, linked list, tree, or other data structure. It forms the basis for many algorithms including searching, sorting, and counting operations.

Multiple choice
  1. Linear search

  2. Binary search

  3. Both (1) & (2)

  4. None of these

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

Both linear search and binary search are fundamental approaches to search operations. Linear search works on unsorted data by checking each element sequentially, while binary search requires sorted data and repeatedly divides the search interval in half, making it much faster for large datasets.

Multiple choice
  1. Binary search

  2. Logical search

  3. Search field

  4. Linear search

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

Linear search traverses sequentially through a list to locate a specific item. It examines each element one by one from the beginning until the target is found or the list ends. This simple approach works on any list but is less efficient than binary search for large, sorted datasets.