Imagine you are working on a system where stability is crucial, and you need to sort a list of objects with identical keys. Which sorting algorithm would you choose, and why?

  • Heap Sort
  • Merge Sort
  • Quick Sort
  • Radix Sort
Merge Sort would be the preferred choice in this scenario. It is a stable sorting algorithm, meaning it preserves the relative order of elements with equal keys. Additionally, its time complexity of O(n log n) ensures efficient sorting, making it suitable for stable sorting tasks.

You are developing a plagiarism detection system for a large document database. Which pattern matching algorithm would you choose and why?

  • Boyer-Moore Algorithm
  • Knuth-Morris-Pratt (KMP) Algorithm
  • Naive Pattern Matching
  • Rabin-Karp Algorithm
For a plagiarism detection system in a large document database, the Rabin-Karp algorithm would be a suitable choice. It utilizes hashing to efficiently detect patterns, making it well-suited for identifying similarities in documents by comparing hash values.

What problem does the Ford-Fulkerson algorithm aim to solve?

  • Counting the number of strongly connected components in a directed graph.
  • Determining the minimum spanning tree of a graph.
  • Finding the shortest path in a graph.
  • Solving the maximum flow problem in a network.
The Ford-Fulkerson algorithm aims to solve the maximum flow problem in a network, where the goal is to find the maximum amount of flow that can be sent from a designated source to a designated sink in a flow network.

What is the time complexity of the selection sort algorithm in the worst-case scenario?

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
The worst-case time complexity of the selection sort algorithm is O(n^2), where 'n' is the number of elements in the array. This is due to the nested loops used to find the minimum element in each iteration.

What type of data structure is a binary tree?

  • Circular Data Structure
  • Linear Data Structure
  • Non-linear Data Structure
  • Sequential Data Structure
A binary tree is a non-linear data structure. Unlike linear structures (e.g., arrays, linked lists), a binary tree represents a hierarchical structure where each node has at most two children, forming branches.

DFS explores as _______ as possible before backtracking.

  • Broad
  • Deep
  • Far
  • Much
DFS explores as deep as possible before backtracking. It follows the depth of a branch in the search space, going as far as it can before backtracking to explore other branches.

You're tasked with designing a system for transmitting large volumes of textual data over a low-bandwidth network connection. How would you employ string compression techniques to minimize data transmission time and bandwidth usage?

  • Apply run-length encoding to replace repeated consecutive characters with a count, reducing redundancy in the transmitted data.
  • Implement lossy compression methods to achieve higher compression ratios, sacrificing some data accuracy for reduced transmission time.
  • Use basic ASCII encoding to represent characters, ensuring minimal overhead during data transmission.
  • Utilize lossless compression algorithms like Lempel-Ziv to identify and eliminate repetitive patterns in the text, ensuring efficient use of bandwidth.
In this scenario, employing lossless compression algorithms such as Lempel-Ziv is effective. Lempel-Ziv identifies and removes repetitive patterns in the text, optimizing bandwidth usage without compromising data integrity. This approach is commonly used in network protocols and file compression.

What is the goal of the Longest Increasing Subsequence problem?

  • To find the length of the longest subarray with elements in strictly increasing order.
  • To find the maximum element in the subarray with elements in non-decreasing order.
  • To find the minimum element in the subarray with elements in strictly increasing order.
  • To find the sum of elements in the longest subarray with consecutive elements.
The goal of the Longest Increasing Subsequence problem is to find the length of the longest subarray with elements in strictly increasing order.

Red-black trees provide _______ guarantees on the height of the tree, ensuring efficient operations.

  • Arbitrary
  • Loose
  • No
  • Strict
Red-black trees provide strict guarantees on the height of the tree. These guarantees ensure that the height of the tree is logarithmic in the number of nodes, leading to efficient search, insertion, and deletion operations.

In a graph containing cycles, _______ sorting cannot be performed as it violates the prerequisite of a directed acyclic graph (DAG).

  • Depth-First
  • Linear
  • Radix
  • Topological
In a graph containing cycles, topological sorting cannot be performed as it violates the prerequisite of a directed acyclic graph (DAG). Topological sorting relies on establishing a linear ordering of vertices, which is not possible in the presence of cycles.