Reversing a linked list recursively involves changing the _______ of each node.

  • Data
  • Next pointer
  • Previous pointer
  • Value
Reversing a linked list recursively involves changing the previous pointer of each node. In each recursive call, the next pointer of each node is redirected to its previous node, gradually reversing the entire list.

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.

Manacher's Algorithm is particularly efficient when the input string contains many _______ palindromes.

  • Disjoint
  • Isolated
  • Non-contiguous
  • Overlapping
Manacher's Algorithm excels when the input string contains many overlapping palindromes. Its linear time complexity remains effective even in scenarios with a high density of overlapping palindromes.

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.

Naive pattern matching compares each character of the pattern with each character of the text _______.

  • In reverse order
  • One by one
  • Randomly
  • Simultaneously
Naive pattern matching compares each character of the pattern with each character of the text one by one. It involves a simple character-by-character comparison, starting from the beginning of the text, and sliding the pattern one position at a time until a match is found or the end of the text is reached.

Metacharacters in regular expressions are special symbols used to represent _______.

  • Numbers
  • Patterns
  • Special characters
  • Variables
Metacharacters in regular expressions are special symbols used to represent special characters. These characters have a special meaning in the context of regular expressions, allowing for flexible and powerful pattern matching.

What are some strategies to avoid infinite loops in DFS?

  • Limiting the search depth
  • Maintain a visited set
  • Resetting the stack
  • Use a timestamp
To avoid infinite loops in DFS, maintaining a visited set is a crucial strategy. This set keeps track of the visited vertices, preventing revisiting the same vertex during the traversal. By marking and checking visited vertices, the algorithm ensures that each vertex is explored only once, effectively avoiding infinite loops. This approach is fundamental for the correct functioning of DFS in scenarios where revisiting nodes must be prevented.

Consider a scenario where you are developing a web browser application. How could you use a stack data structure to implement the functionality of the "back" and "forward" buttons?

  • Implement a hash table to store URLs and retrieve them based on navigation history.
  • Maintain a queue to store URLs, and for "back" and "forward," dequeue and enqueue, respectively.
  • Store the visited URLs in a stack. For "back," pop from the stack, and for "forward," push into another stack.
  • Use a linked list to store URLs, and traverse backward and forward for "back" and "forward" actions.
A stack can be used to implement the "back" and "forward" functionality by storing visited URLs. Popping from the stack for "back" and pushing into another stack for "forward" allows efficient navigation history management.