Selection sort's time complexity can be improved to _______ by implementing certain optimizations.

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
Selection sort's time complexity can be improved to O(n log n) by implementing certain optimizations, such as using more advanced data structures or algorithms to perform the selection in a more efficient manner.

Explain the rotation operations used in AVL trees and their significance in maintaining balance.

  • Primary and secondary rotations; Primary rotations adjust immediate subtrees, while secondary rotations modify distant subtrees.
  • Simple and complex rotations; Simple rotations involve basic adjustments, while complex rotations involve intricate reconfigurations.
  • Single and double rotations; Single rotations involve left or right rotations, while double rotations involve combinations of single rotations.
  • Triple and quadruple rotations; Triple rotations involve three consecutive rotations, while quadruple rotations involve four rotations simultaneously.
Rotation operations used in AVL trees are single and double rotations. Single rotations include left rotations and right rotations, which help maintain balance by adjusting the heights of subtrees. Double rotations are combinations of single rotations performed to restore balance in specific cases, such as the double rotation involving left-right or right-left rotations.

Discuss the advantages and disadvantages of using arrays in programming.

  • Dynamic size, easy to insert and delete elements, cache-friendly.
  • Efficient for random access, fixed size, memory-friendly.
  • Flexible size, efficient for small datasets, cache-unfriendly.
  • Limited size, inefficient for dynamic resizing, contiguous memory.
Arrays in programming offer advantages such as efficient random access, fixed size, and memory-friendly characteristics. However, they have disadvantages like a fixed size, inefficient dynamic resizing, and the requirement for contiguous memory.

Explain how matrix exponentiation can be utilized to compute Fibonacci numbers in logarithmic time complexity.

  • By representing the problem in terms of matrix exponentiation, Fibonacci numbers can be computed in logarithmic time complexity.
  • Matrix exponentiation can be used to compute Fibonacci numbers in linear time complexity.
  • Matrix exponentiation has no relevance to computing Fibonacci numbers.
  • Matrix exponentiation is only applicable to square matrices.
Matrix exponentiation offers an efficient way to compute Fibonacci numbers in logarithmic time complexity. By expressing the problem as a matrix multiplication and leveraging exponentiation properties, the computation becomes more efficient compared to traditional recursive approaches.

In A* search, what role do heuristic functions play in guiding the search process?

  • Heuristic functions are applied only to the start node
  • Heuristic functions determine the optimal path
  • Heuristic functions have no impact on the search process
  • Heuristic functions provide an estimate of the remaining cost
Heuristic functions in A* search provide an estimate of the remaining cost from a given node to the goal. This estimate guides the algorithm to prioritize paths that seem more promising in reaching the goal efficiently.

How does the performance of regular expression matching change with the complexity of the pattern and input text?

  • Performance degrades exponentially with the complexity of the pattern and input text.
  • Performance improves as both pattern and input text become more complex.
  • Performance is independent of the pattern complexity but depends on the input text complexity.
  • Performance remains constant regardless of the complexity of the pattern and input text.
The performance of regular expression matching typically degrades exponentially with the complexity of both the pattern and input text. More complex patterns and longer input texts can lead to significantly increased processing time.

How is the next number in the Fibonacci sequence generated from the previous two numbers?

  • Addition of the two preceding numbers.
  • Division of the two preceding numbers.
  • Multiplication of the two preceding numbers.
  • Subtraction of the two preceding numbers.
The next number in the Fibonacci sequence is generated by adding the two preceding numbers. For example, if the last two numbers are 'a' and 'b', then the next number is 'a + b'. This recurrence relation defines the Fibonacci sequence.

How does Dijkstra's algorithm guarantee the shortest path in a graph with non-negative edge weights?

  • Always selects the smallest tentative distance
  • Considers random paths
  • Prioritizes longest paths
  • Utilizes heuristics for optimization
Dijkstra's algorithm guarantees the shortest path by always selecting the smallest tentative distance, ensuring that the chosen path at each step is the most optimal. It relies on a greedy approach and the non-negativity of edge weights to consistently find the shortest paths. Heuristics, random paths, or prioritizing longest paths are not part of Dijkstra's algorithm logic.

The time complexity of radix sort is _______ in most scenarios.

  • O(k * n)
  • O(n * log n)
  • O(n + k)
  • O(n^2)
The time complexity of radix sort is O(k * n), where 'k' is the number of digits or components in the keys, and 'n' is the number of elements. It is linear and often more efficient.

In the Fractional Knapsack Problem, items can be divided to fit into the knapsack partially, whereas in the 0/1 Knapsack Problem, items must be chosen _______.

  • Arbitrarily
  • Completely
  • Exponentially
  • Sequentially
In the 0/1 Knapsack Problem, items must be chosen completely, meaning either an item is included in its entirety or not at all. On the other hand, the Fractional Knapsack Problem allows items to be divided and included partially.

Can LCS be applied to strings of different lengths? Why or why not?

  • No, because it can only be applied to arrays, not strings.
  • No, because it only works on strings of equal lengths.
  • Yes, as long as the algorithm is modified to handle different lengths.
  • Yes, without any modification.
Yes, the longest common subsequence (LCS) algorithm can be applied to strings of different lengths. It involves modifying the dynamic programming approach to handle the differences in lengths by considering all possible pairs of substrings and building the LCS table accordingly.

How does the suffix tree data structure contribute to solving the longest common substring problem efficiently?

  • Suffix tree allows for efficient pattern matching and finding common substrings by storing all suffixes of a string in a compressed tree structure.
  • Suffix tree enables quick sorting of substrings based on their lengths.
  • Suffix tree performs a linear scan of the input strings to find common characters.
  • Suffix tree uses a greedy algorithm to find the longest common substring.
The suffix tree data structure contributes to solving the longest common substring problem efficiently by storing all suffixes of a string in a compressed tree structure. This allows for fast pattern matching and identification of common substrings.