TMA 01 Part 2: Collections, Algorithms, and Coding Style
63 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the common way to represent a graph in computer science?

  • Using a tree data structure
  • Using a list of vertices and edges
  • Using a matrix of adjacencies (correct)
  • Using a set of nodes and a set of edges

Which graph traversal algorithm is used to visit all reachable nodes from a given starting node?

  • Dijkstra's algorithm
  • Depth-First Search (DFS)
  • Breadth-First Search (BFS) (correct)
  • Kruskal's algorithm

What is the time complexity of Breadth-First Search (BFS) on a graph with $V$ vertices and $E$ edges?

  • $O(E)$
  • $O(V + E)$ (correct)
  • $O(V)$
  • $O(V^2)$

Which graph data structure is used to represent a tree?

<p>Rooted tree (D)</p> Signup and view all the answers

What is the purpose of Kruskal's algorithm in graph theory?

<p>To find the minimum spanning tree of a weighted graph (C)</p> Signup and view all the answers

What topic does the section 'Undirected graph components' in the text fall under?

<p>Graphs (B)</p> Signup and view all the answers

Which section in the text mentions 'Minimum spanning tree'?

<p>Graphs (C)</p> Signup and view all the answers

In which part of the text would you expect to find information about 'Topological sort'?

<p>Graphs (A)</p> Signup and view all the answers

Which part of the text discusses 'Jousting' and 'Dot product'?

<p>Graphs (A)</p> Signup and view all the answers

'Longest common subsequence' and 'Knapsack' are topics found in which part of the text?

<p>Dynamic Programming (C)</p> Signup and view all the answers

'Borrow a book' and 'Levenshtein distance' are mentioned in which part of the text?

<p>Complexity classes (C)</p> Signup and view all the answers

What is the purpose of the adjacency matrix representation of a graph?

<p>To represent the connectivity between nodes in a graph (A)</p> Signup and view all the answers

Which graph traversal algorithm is used to visit all reachable nodes from a given starting node?

<p>Depth-First Search (DFS) (D)</p> Signup and view all the answers

What is the purpose of Topological Sort in graph theory?

<p>To order the nodes of a directed graph based on their dependencies (B)</p> Signup and view all the answers

What is the purpose of the adjacency list representation of a graph?

<p>To allow for fast lookups of node degrees (A)</p> Signup and view all the answers

What is the purpose of Kruskal's algorithm in graph theory?

<p>To find the minimum spanning tree of a graph (D)</p> Signup and view all the answers

What is the purpose of the edge list representation of a graph?

<p>To efficiently store the edges of a sparse graph (D)</p> Signup and view all the answers

What is the most common way to represent a graph in computer science?

<p>Adjacency list (D)</p> Signup and view all the answers

Which graph traversal algorithm is used to visit all reachable nodes from a given starting node?

<p>Breadth-First Search (BFS) (B)</p> Signup and view all the answers

What is the time complexity of Breadth-First Search (BFS) on a graph with $V$ vertices and $E$ edges?

<p>$O(V + E)$ (B)</p> Signup and view all the answers

Which graph data structure is used to represent a tree?

<p>Rooted tree (C)</p> Signup and view all the answers

What is the purpose of Kruskal's algorithm in graph theory?

<p>To find the minimum spanning tree of a graph (D)</p> Signup and view all the answers

What is the purpose of Prim's algorithm in graph theory?

<p>To find the minimum spanning tree of a graph (D)</p> Signup and view all the answers

What is the purpose of Dijkstra's algorithm in graph theory?

<p>To find the shortest path between two nodes (A)</p> Signup and view all the answers

What is the purpose of Topological Sort in graph theory?

<p>To find a linear ordering of the vertices in a directed acyclic graph (DAG) (D)</p> Signup and view all the answers

What is the purpose of the Strongly Connected Components (SCC) algorithm in graph theory?

<p>To partition a directed graph into its strongly connected components (C)</p> Signup and view all the answers

What is the purpose of the Tarjan's algorithm in graph theory?

<p>To find the strongly connected components of a directed graph (B)</p> Signup and view all the answers

What starts with an empty candidate sequence or set and extends it one item at a time?

<p>Partial candidates (D)</p> Signup and view all the answers

Which technique only generates a fraction of all candidates making it more efficient than exhaustive search?

<p>Tree traversal (C)</p> Signup and view all the answers

In backtracking, what core traversal is used for generating permutations and subsets?

<p>Tree traversal (C)</p> Signup and view all the answers

When extending a candidate in backtracking, what does the algorithm do if it cannot lead to a solution or a better solution?

<p>Goes back and tries a different item or candidate (A)</p> Signup and view all the answers

At the core of backtracking is a recursive pre-order traversal of what structure?

<p>Tree (B)</p> Signup and view all the answers

Which problems in M269 are solved using backtracking on sequences of non-duplicate items or subsets of items?

<p>Constraint satisfaction and optimization problems (D)</p> Signup and view all the answers

What is the purpose of the first check in a backtracking algorithm?

<p>To check if it's worth extending the candidate with a chosen item (C)</p> Signup and view all the answers

What is the purpose of the second check in a backtracking algorithm?

<p>To check if a candidate satisfies the global constraints (B)</p> Signup and view all the answers

How can the search space be further pruned for subset problems in a backtracking algorithm?

<p>By sorting the items in advance and stopping when a candidate cannot be extended (B)</p> Signup and view all the answers

What is the purpose of the third check in a backtracking algorithm for optimization problems?

<p>To compute the value of each solution found and update the current best (B)</p> Signup and view all the answers

What represents the local constraints in a backtracking algorithm?

<p>The conditions that a partial candidate must satisfy to be extended (A)</p> Signup and view all the answers

In the context of backtracking algorithms, what do 'candidates' and 'extensions' represent?

<p>Candidates are partial solutions, and extensions are the steps to complete them (B)</p> Signup and view all the answers

What is the primary purpose of backtracking?

<p>To generate candidates incrementally and prune the search space (C)</p> Signup and view all the answers

Which condition is necessary for backtracking to be applicable?

<p>Each solution (and candidate) is a collection of items (A)</p> Signup and view all the answers

What is the primary advantage of backtracking over exhaustive search?

<p>It is more efficient because it can prune the search space substantially (A)</p> Signup and view all the answers

What is the primary difference between global constraints and local constraints in backtracking?

<p>Global constraints apply to the entire solution, while local constraints apply to individual items (D)</p> Signup and view all the answers

In the context of backtracking, what is a partial candidate?

<p>An incomplete candidate that satisfies all constraints so far (B)</p> Signup and view all the answers

What is the typical approach used by backtracking algorithms to explore the search space?

<p>Depth-first search (A)</p> Signup and view all the answers

What is the primary advantage of backtracking over exhaustive search?

<p>Backtracking can generate fewer candidates by pruning the search space (B)</p> Signup and view all the answers

What is the primary difference between global constraints and local constraints in backtracking?

<p>Global constraints apply to the entire candidate solution, while local constraints apply to individual items in the candidate (D)</p> Signup and view all the answers

When extending a candidate in backtracking, what does the algorithm do if it cannot lead to a solution or a better solution?

<p>The algorithm backtracks to the previous step and explores a different extension (C)</p> Signup and view all the answers

How can the search space be further pruned for subset problems in a backtracking algorithm?

<p>By only considering unique items when extending the candidate (A)</p> Signup and view all the answers

What is the purpose of the first check in a backtracking algorithm?

<p>To determine if the current candidate is a complete solution (D)</p> Signup and view all the answers

Which technique only generates a fraction of all candidates, making it more efficient than exhaustive search?

<p>Backtracking (A)</p> Signup and view all the answers

What is the primary advantage of backtracking over exhaustive search?

<p>Backtracking explores the search space more efficiently by pruning branches that do not satisfy the local constraints. (D)</p> Signup and view all the answers

What do the 'local constraints' represent in the context of a backtracking algorithm?

<p>The constraints that apply to the current candidate solution, regardless of the rest of the solution. (C)</p> Signup and view all the answers

What is the purpose of the first check in a backtracking algorithm?

<p>To check if extending the current candidate solution with a chosen item is worth pursuing, based on the local constraints. (C)</p> Signup and view all the answers

How can the search space be further pruned for subset problems in a backtracking algorithm?

<p>By sorting the items in advance so that when one can't extend a candidate, neither can any of the subsequent items. (B)</p> Signup and view all the answers

What is the primary difference between global constraints and local constraints in a backtracking algorithm?

<p>Global constraints apply to the entire candidate solution, while local constraints only apply to the current item being considered. (C)</p> Signup and view all the answers

What is the key ingredient that turns an exhaustive traversal into a backtracking algorithm?

<p>The check to see if it's worth extending the current candidate solution with a chosen item, based on the local constraints. (B)</p> Signup and view all the answers

What is a key advantage of backtracking over exhaustive search?

<p>Prunes vast parts of the search space (B)</p> Signup and view all the answers

In backtracking, where are global constraints checked?

<p>On all candidate sequences (D)</p> Signup and view all the answers

What differentiates backtracking from brute-force search in terms of candidate generation?

<p>Backtracking prunes candidate generation (A)</p> Signup and view all the answers

How does backtracking handle local constraints during candidate generation?

<p>Local constraints are checked for each extension (A)</p> Signup and view all the answers

Why is backtracking more efficient than generating all permutations?

<p>It prunes vast parts of the search space (B)</p> Signup and view all the answers

What is a distinguishing feature of backtracking compared to brute-force search regarding the search space?

<p>'Prunes parts of the search space' (A)</p> Signup and view all the answers

More Like This

Network Crisis Problem-Solving Quiz
5 questions
Data Structures and Algorithms Chapter 1.3
63 questions
Data Structures and Algorithms Chapter 1
61 questions
Research Design in IT
24 questions

Research Design in IT

FabulousCentaur avatar
FabulousCentaur
Use Quizgecko on...
Browser
Browser