An AVL tree is a self-balancing binary search tree where the _______ factor of each node is at most _______.

  • Balancing, 1
  • Degree, 2
  • Depth, 1
  • Height, 0
An AVL tree is a self-balancing binary search tree where the height factor (also known as the balance factor) of each node is at most 1. The balance factor is the difference between the height of the left and right subtrees.

You are tasked with finding a specific word in a large document. Discuss whether linear search would be an appropriate approach and propose alternative strategies if necessary.

  • Binary search
  • Hashing
  • Indexing
  • Linear search
Linear search may not be the most appropriate approach for searching a specific word in a large document due to its time complexity. Binary search, hashing, or indexing could be more suitable alternatives. Binary search is efficient for sorted data, hashing provides constant time complexity on average, and indexing can expedite search operations by creating a mapping between words and their locations.

Suppose you are working on a project where the graph may contain negative edge weights, but you need to find the shortest paths from a single source vertex. Which algorithm would you implement, and why?

  • Bellman-Ford Algorithm
  • Dijkstra's Algorithm
  • Floyd-Warshall Algorithm
  • Kruskal's Algorithm
The Bellman-Ford Algorithm is the appropriate choice for scenarios with graphs containing negative edge weights. Unlike Dijkstra's Algorithm, Bellman-Ford can handle negative weights, making it suitable for finding the shortest paths from a single source vertex in such scenarios.

Can DFS be used to find the shortest path in a weighted graph? Explain why or why not.

  • No, DFS cannot guarantee the shortest path in a weighted graph because it may explore longer paths first.
  • No, DFS is only applicable to unweighted graphs and cannot handle weighted edges.
  • Yes, DFS can be used to find the shortest path in a weighted graph by considering edge weights during traversal.
  • Yes, DFS is always the preferred algorithm for finding the shortest path in a weighted graph.
No, DFS cannot guarantee the shortest path in a weighted graph because it may explore longer paths first. DFS is more suitable for unweighted graphs, and algorithms like Dijkstra's or Bellman-Ford are preferred for finding the shortest path in weighted graphs.

Compared to DFS, BFS typically requires more _______.

  • Computation
  • Input
  • Memory
  • Time
Compared to DFS, BFS typically requires more memory. This is because BFS stores all nodes at the current level in memory, leading to higher space complexity compared to DFS, which explores as far as possible along each branch before backtracking.

You're designing a scheduling application where tasks are added and removed frequently. Would you use a singly linked list or a doubly linked list to implement the task list? Justify your choice.

  • Array
  • Circular linked list
  • Doubly linked list
  • Singly linked list
In this scenario, a doubly linked list would be a better choice. The reason is that tasks are added and removed frequently, and a doubly linked list allows for easy insertion and deletion of elements at both the beginning and end of the list, providing efficient operations for a scheduling application.

How does the presence of cycles in a graph affect the possibility of performing topological sorting?

  • Cycles have no impact on topological sorting.
  • Cycles make topological sorting deterministic.
  • Cycles make topological sorting impossible.
  • Cycles make topological sorting more efficient.
The presence of cycles in a graph makes topological sorting impossible. Topological sorting is designed for directed acyclic graphs (DAGs), and cycles introduce ambiguity in the order of nodes, preventing a clear linear ordering of vertices.

What is the significance of topological sorting in dependency resolution?

  • It helps in identifying isolated components in the graph.
  • It is used to compute the transitive closure of a graph.
  • It is used to find the maximum flow in a network.
  • It provides a linear order of tasks or events, allowing for systematic resolution of dependencies.
Topological sorting is significant in dependency resolution as it provides a linear order of tasks or events. This order ensures that tasks dependent on others are processed in the correct sequence, helping in the systematic resolution of dependencies.

In a binary tree, what is the maximum number of children a node can have?

  • 1
  • 2
  • 3
  • 4
In a binary tree, each node can have a maximum of two children. This characteristic distinguishes binary trees from other tree structures and allows for efficient search and manipulation.

Suppose you are working on a genetic research project where you need to compare DNA sequences to identify common genetic patterns. Explain how LCS can be applied to this scenario and discuss any challenges you might encounter.

  • By comparing DNA sequences lengthwise.
  • By focusing only on specific nucleotide bases.
  • By identifying the longest common subsequence in DNA sequences.
  • By randomly aligning DNA sequences for comparison.
Applying LCS in genetic research involves identifying the longest common subsequence in DNA sequences, aiding in recognizing common genetic patterns. Challenges may include handling gaps, mutations, and variations in sequence length.

Explain the role of topological sorting in scheduling tasks in project management.

  • Topological sorting helps in identifying the dependencies among tasks and establishes a valid order for task execution.
  • Topological sorting is not applicable in project management; it is only used in graph theory.
  • Topological sorting is used to sort tasks based on their completion times.
  • Topological sorting randomly assigns tasks without considering dependencies.
In project management, topological sorting plays a crucial role in scheduling tasks. It helps identify task dependencies and establishes a valid order for task execution, ensuring that tasks are completed in the correct sequence.

DFS can be optimized by _______ the vertices in a particular order before traversal to achieve better performance.

  • Ordering
  • Randomizing
  • Shuffling
  • Sorting
DFS can be optimized by ordering the vertices in a particular way before traversal. The choice of vertex order can impact the algorithm's performance, and certain orders may result in a more efficient exploration of the graph.