In the context of strings, what does the term "edit" refer to in the Edit Distance algorithm?

  • All of the above.
  • Deleting characters from a string.
  • Inserting characters into a string.
  • Modifying characters in a string.
In the context of strings and the Edit Distance algorithm, the term "edit" refers to all three operations: deleting characters, inserting characters, and modifying characters in a string. These operations are used to transform one string into another.

Which shortest path algorithm is suitable for finding the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights?

  • Bellman-Ford Algorithm
  • Dijkstra's Algorithm
  • Floyd-Warshall Algorithm
  • Prim's Algorithm
Dijkstra's Algorithm is suitable for finding the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights. It uses a greedy approach, iteratively selecting the vertex with the smallest known distance to the source.

Linear search examines each element in the array _______ until the desired element is found or the end of the array is reached.

  • None of the above
  • One by one
  • Randomly
  • Skip a few at a time
Linear search examines each element in the array one by one until the desired element is found or the end of the array is reached. It starts from the beginning and checks each element sequentially.

Selecting a _______ pivot element in Quick Sort can significantly reduce its time complexity.

  • Largest
  • Middle
  • Random
  • Smallest
Selecting a random pivot element in Quick Sort can significantly reduce its time complexity by minimizing the chance of encountering the worst-case scenario, leading to more balanced partitions.

One of the key advantages of merge sort is its _______ time complexity in all cases.

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
One of the key advantages of merge sort is its O(n log n) time complexity in all cases. This makes it more efficient than some other sorting algorithms, especially in scenarios with large datasets.

Suppose you're designing a software tool for identifying similar images. Discuss how you would adapt algorithms for the longest common substring problem to compare image data and find common features.

  • By comparing the image sizes without analyzing the actual content.
  • By converting image data into a format suitable for string comparison and applying longest common substring algorithms.
  • By focusing only on the overall color distribution in the images.
  • By randomly selecting pixels in the images for substring comparison.
Adapting longest common substring algorithms for image comparison involves converting image data into a format suitable for string comparison. This allows for the identification of common features by analyzing substrings within the image data.

How does topological sorting differ from other sorting algorithms like bubble sort or merge sort?

  • Topological sorting has a time complexity of O(n^2), whereas bubble sort and merge sort have better time complexities of O(n^2) and O(n log n) respectively.
  • Topological sorting is a comparison-based sorting algorithm, similar to bubble sort and merge sort.
  • Topological sorting is an in-place sorting algorithm, whereas bubble sort and merge sort require additional space for sorting.
  • Topological sorting is specifically designed for directed acyclic graphs (DAGs) and maintains the order of dependencies, while bubble sort and merge sort are general-purpose sorting algorithms for arrays.
Topological sorting is specialized for directed acyclic graphs (DAGs), ensuring a valid sequence of dependencies, unlike general-purpose sorting algorithms such as bubble sort and merge sort.

How does merge sort perform in terms of time complexity compared to other sorting algorithms for large datasets?

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
Merge sort excels in time complexity for large datasets, performing at O(n log n), which is more efficient than O(n^2) algorithms like bubble sort or insertion sort. This makes merge sort a preferred choice for large-scale sorting tasks.

In the coin change problem, what is meant by the term "minimum number of coins"?

  • The fewest number of coins required to represent a given amount.
  • The least valuable coins in the currency.
  • The lowest denomination of coins in the given set.
  • The smallest physical size of the coins.
In the coin change problem, the term "minimum number of coins" refers to the fewest number of coins needed to represent a given target amount. The goal is to optimize the combination of coins used to minimize the total count.

Compare and contrast separate chaining and open addressing collision resolution strategies in hash tables.

  • Both methods involve creating secondary data structures to handle collisions. Separate chaining uses linked lists, while open addressing stores elements directly in the hash table.
  • Separate chaining and open addressing are identical in their approach to collision resolution.
  • Separate chaining and open addressing both involve redistributing colliding elements to other locations. Separate chaining uses a single array, while open addressing uses multiple arrays.
  • Separate chaining uses a single array to store all elements, while open addressing distributes elements across multiple arrays. Both methods avoid collisions by using dynamic resizing.
Separate chaining and open addressing are two common strategies for handling collisions in hash tables. Separate chaining involves creating linked lists at each index to store colliding elements, while open addressing places elements directly in the hash table, using methods like linear probing or quadratic probing to find alternative locations for collisions.