SA4 Flashcards

(41 cards)

1
Q

What is a greedy algorithm?
Group of answer choices

An algorithm that always finds the globally optimal solution

An algorithm that solves all problems in linear time

An algorithm that makes the locally optimal choice at each stage

An algorithm that uses recursion to solve problems

A

An algorithm that makes the locally optimal choice at each stage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following is NOT a component of a greedy algorithm?
Group of answer choices

A randomization function

A candidate set

A feasibility function

A selection function

A

A randomization function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the main advantage of using a greedy algorithm?
Group of answer choices

It has no disadvantages

It works for all types of problems

It is easy to implement and analyze

It always guarantees the optimal solution

A

It is easy to implement and analyze

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the main advantage of using a greedy algorithm?
Group of answer choices

It has no disadvantages

It works for all types of problems

It is easy to implement and analyze

It always guarantees the optimal solution

A

It is easy to implement and analyze

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which algorithm is used to find the Minimum Spanning Tree (MST) of a graph?
Group of answer choices

Merge Sort Algorithm

Binary Search Algorithm

Prim’s Algorithm

Dijkstra’s Algorithm

A

Prim’s Algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the time complexity of Prim’s Algorithm when using an adjacency matrix?
Group of answer choices

O(V²)

O(V log E)

O(E²)

O(E log V)

A

O(V²)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of Kruskal’s Algorithm?
Group of answer choices

To sort edges in ascending order

To find the Minimum Spanning Tree (MST) of a graph

To detect cycles in a graph

To find the shortest path in a graph

A

To find the Minimum Spanning Tree (MST) of a graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the time complexity of Kruskal’s Algorithm?
Group of answer choices

O(E²)

O(E log E)

O(V log V)

O(V²)

A

O(E log E)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which algorithm is used to find the shortest path from a single source node to all other nodes in a graph?
Group of answer choices

Kruskal’s Algorithm

Dijkstra’s Algorithm

Floyd-Warshall Algorithm

Prim’s Algorithm

A

Dijkstra’s Algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Who invented Dijkstra’s Algorithm?
Group of answer choices

Edsger W. Dijkstra

Vojtech Jarnik

Robert C. Prim

Joseph Kruskal

A

Edsger W. Dijkstra

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does Dijkstra’s Algorithm use to determine the shortest path?
Group of answer choices

Breadth-First Search

Greedy approach with edge weights

Depth-First Search

Dynamic Programming

A

Greedy approach with edge weights

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Minimum Spanning Tree (MST)?
Group of answer choices

A tree that only connects two vertices

A tree that connects all vertices with the minimum total edge weight

A tree that includes cycles

A tree that contains all the edges of a graph

A

A tree that connects all vertices with the minimum total edge weight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following is NOT an application of Minimum Spanning Trees?
Group of answer choices

Sorting algorithms

Real-time face tracking

Cluster analysis

Network design

A

Sorting algorithms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In Kruskal’s Algorithm, how are edges processed?
Group of answer choices

In ascending order of weight

Based on the degree of vertices

Randomly

In descending order of weight

A

In ascending order of weight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In Prim’s Algorithm, how is the next edge selected?
Group of answer choices

The edge with the lowest weight connecting a vertex in the tree to a vertex outside

The first edge in the sorted list

The edge with the highest weight

Any random edge

A

The edge with the lowest weight connecting a vertex in the tree to a vertex outside

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the main disadvantage of Prim’s Algorithm?
Group of answer choices

It always produces incorrect results

It is too slow for small graphs

It cannot handle disconnected graphs

It requires searching the list of edges repeatedly

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What happens if adding an edge in Kruskal’s Algorithm forms a cycle?
Group of answer choices

The edge is added anyway

The graph is considered invalid

The edge is discarded

The algorithm stops

A

The edge is discarded

17
Q

What is the initial step in Dijkstra’s Algorithm?
Group of answer choices

Assign maximum distance to all vertices

Mark all vertices as visited

Assign zero distance to the source vertex

Sort all edges by weight

A

Assign maximum distance to all vertices

18
Q

What data structure is commonly used in Dijkstra’s Algorithm to improve efficiency?
Group of answer choices

Priority Queue

Stack

Linked List

Array

A

Priority Queue

19
Q

Which of the following is TRUE about greedy algorithms?
Group of answer choices

They require dynamic programming to work

They may yield locally optimal solutions that approximate a globally optimal solution

They are only used for sorting problems

They always guarantee the optimal solution

A

They may yield locally optimal solutions that approximate a globally optimal solution

20
Q

What is the primary difference between Prim’s and Kruskal’s Algorithms?
Group of answer choices

Prim’s Algorithm builds the MST one vertex at a time, while Kruskal’s builds it one edge at a time

Kruskal’s Algorithm uses a priority queue, while Prim’s does not

Prim’s Algorithm is recursive, while Kruskal’s is iterative

Prim’s Algorithm is used for directed graphs, while Kruskal’s is for undirected graphs

A

Prim’s Algorithm builds the MST one vertex at a time, while Kruskal’s builds it one edge at a time

21
Q

What is Dynamic Programming?
Group of answer choices

A method for solving problems by breaking them into independent sub-problems

A method that avoids recursion

A method for solving problems by breaking them into overlapping sub-problems and storing their results

A method that only works for greedy algorithms

A

A method for solving problems by breaking them into overlapping sub-problems and storing their results

22
Q

Who developed the Dynamic Programming method?
Group of answer choices

Alan Turing

Richard Bellman

Edsger Dijkstra

Donald Knuth

A

Richard Bellman

23
Q

Which of the following is NOT a characteristic of Dynamic Programming?
Group of answer choices

Overlapping sub-problems

Memoization

Independent sub-problems

Optimal substructure

A

Independent sub-problems

24
Which problem is often solved using Dynamic Programming? Group of answer choices Binary search Fibonacci number series Sorting a list Matrix multiplication
Fibonacci number serie
25
What is the time complexity of the naive recursive Fibonacci algorithm? Group of answer choices O(n) O(log n) O(n^2) O(2^n)
O(2^n)
26
What is the main advantage of using Dynamic Programming to solve the Fibonacci sequence? Group of answer choices It allows parallel computation It eliminates the need for recursion It avoids repeated calculations by storing results It reduces the space complexity to O(1)
It avoids repeated calculations by storing results
27
What does the Knapsack Problem aim to optimize? Group of answer choices The volume of the knapsack The total value of items in the knapsack while respecting the weight limit The total weight of items in the knapsack The number of items in the knapsack
The total value of items in the knapsack while respecting the weight limit
28
What is the time complexity of solving the Knapsack Problem using Dynamic Programming? Group of answer choices O(2^n) O(n^2) O(nW), where W is the knapsack capacity O(n log n)
O(nW), where W is the knapsack capacity
29
In the Tower of Hanoi problem, what is the minimum number of moves required to solve it with n disks? Group of answer choices n! 2^n - 1 n^2 2n
2^n - 1
29
Which rule is NOT part of the Tower of Hanoi puzzle? Group of answer choices No larger disk can sit over a smaller disk Only one disk can be moved at a time Disks can be moved directly from the source to the destination without using the auxiliary peg Only the top disk can be removed
Disks can be moved directly from the source to the destination without using the auxiliary peg
30
What is the Floyd-Warshall algorithm used for? Group of answer choices Finding the shortest paths between all pairs of vertices in a graph Finding the shortest path from a single source Detecting cycles in a graph Sorting edges in a graph
Finding the shortest paths between all pairs of vertices in a graph
31
Which of the following problems can be solved using the Floyd-Warshall algorithm? Group of answer choices Minimum spanning tree All-pairs shortest path Single-source shortest path Graph coloring
All-pairs shortest path
31
What is the time complexity of the Floyd-Warshall algorithm? Group of answer choices O(2^n) O(n log n) O(n^2) O(n^3)
O(n^3)
32
What is Dijkstra's algorithm primarily used for? Group of answer choices Finding the longest path in a graph Solving the Knapsack Problem Finding the shortest path from a single source to all other nodes Detecting negative cycles in a graph
Finding the shortest path from a single source to all other nodes
33
Which data structure is commonly used in Dijkstra's algorithm? Group of answer choices Hash table Stack Priority queue Queue
Priority queue
34
What is the time complexity of Dijkstra's algorithm using a priority queue? Group of answer choices O(n log n) O(n) O(V^2) O((V + E) log V), where V is the number of vertices and E is the number of edges
O((V + E) log V), where V is the number of vertices and E is the number of edges
35
Which of the following is NOT a limitation of Dijkstra's algorithm? Group of answer choices It is less efficient for dense graphs It may fail if there are disconnected components It requires the graph to be acyclic It cannot handle graphs with negative edge weights
It requires the graph to be acyclic
36
What is memoization in the context of Dynamic Programming? Group of answer choices Storing the results of expensive function calls and reusing them when needed Breaking down a problem into smaller sub-problems Eliminating recursion entirely Using a bottom-up approach
Storing the results of expensive function calls and reusing them when needed
37
Which problem involves finding the most valuable subset of items under a weight constraint? Group of answer choices Knapsack Problem Tower of Hanoi Fibonacci sequence Shortest path problem
Knapsack Problem
38
What is the primary difference between Dynamic Programming and Divide and Conquer? Group of answer choices Dynamic Programming uses recursion, while Divide and Conquer does not Divide and Conquer uses memoization Dynamic Programming solves overlapping sub-problems, while Divide and Conquer solves independent sub-problems Dynamic Programming is only used for optimization problems
Dynamic Programming solves overlapping sub-problems, while Divide and Conquer solves independent sub-problems