SA2-ALGORITHM Flashcards

(40 cards)

1
Q

What is a brute-force approach in algorithm design?
Group of answer choices

A method that uses advanced techniques to solve problems efficiently

A straightforward approach based directly on the problem’s statement and definitions

A technique that avoids generating all potential solutions

A method that relies solely on machine learning algorithms

A

A straightforward approach based directly on the problem’s statement and definitions

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

Which of the following is NOT a strength of brute-force algorithms?
Group of answer choices

Wide applicability

Simplicity

High efficiency

Reasonable algorithms for some important problems

A

High efficiency

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

What is the primary goal of selection sort?
Group of answer choices

To repeatedly find the maximum element and place it at the end

To repeatedly find the minimum element and place it at the beginning

To divide the array into two equal halves

To compare adjacent elements and swap them

A

To repeatedly find the minimum element and place it at the beginning

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

In selection sort, how many subarrays are maintained during the sorting process?
Group of answer choices

Two (sorted and unsorted)

Three (sorted, unsorted, and temporary)

One (entire array)

Four (sorted, unsorted, temporary, and pivot)

A

Two (sorted and unsorted)

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

What is the time complexity of brute-force string matching in the worst case?
Group of answer choices

Θ(n + m)

Θ(n log m)

Θ(mn)

Θ(n^2)

A

Θ(mn)

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

What is exhaustive search primarily used for?
Group of answer choices

Solving problems using dynamic programming

Generating all potential solutions to a problem systematically

Reducing the problem size by half

Finding approximate solutions

A

Generating all potential solutions to a problem systematically

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

Which step aligns the pattern at the beginning of the text in brute-force string matching?
Group of answer choices

Step 1

Step 2

Step 3

Step 4

A

Step 1

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

Which problem involves finding the shortest tour that passes through all cities exactly once?
Group of answer choices

Knapsack Problem

Traveling Salesman Problem

Selection Sort Problem

String Matching Problem

A

Traveling Salesman Problem

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

hat is the total cost of the tour a→b→c→d→a in the Traveling Salesman Problem example?
Group of answer choices

21

17

20

15

A

17

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

Which algorithm is commonly used as a heuristic for solving the Traveling Salesman Problem?
Group of answer choices

Selection Sort Algorithm

Brute-Force String Matching Algorithm

Nearest Neighbor Algorithm

Exhaustive Search Algorithm

A

Nearest Neighbor Algorithm

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

What is the knapsack capacity in the given example of the Knapsack Problem?
Group of answer choices

10

12

16

20

A

16

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

Which subset has the highest total value without exceeding the knapsack capacity in the example?
Group of answer choices

{1, 2, 3}

{1, 3, 4}

{2, 3}

{1, 2, 4}

A

{2, 3}

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

What is the efficiency of the exhaustive search approach for the Knapsack Problem?
Group of answer choices

Θ(n log n)

Θ(n^2)

Θ(2^n)

Θ(n!)

A

Θ(2^n)

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

Which of the following is true about brute-force algorithms?
Group of answer choices

They are always efficient

They rarely yield efficient algorithms

They are the most constructive design techniques

They avoid comparing all possible solutions

A

They rarely yield efficient algorithms

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

In the Traveling Salesman Problem, what does a Hamiltonian circuit represent?
Group of answer choices

A path that visits some cities exactly once

A path that visits all cities exactly once and returns to the starting city

A path that visits all cities multiple times

A path that skips one city

A

A path that visits all cities exactly once and returns to the starting city

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

What is the first step in the Nearest Neighbor Algorithm for TSP?
Group of answer choices

Choose a starting vertex

Calculate the total cost of the tour

List all possible tours

Compare edge weights

A

Choose a starting vertex

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

Which of the following is NOT a combinatorial object?
Group of answer choices

Permutations

Combinations

Matrices

Subsets

17
Q

What is the output of the brute-force string matching algorithm if no match is found?
Group of answer choices

0

The length of the pattern

-1

The length of the text

18
Q

What does row minimization achieve in the Traveling Salesman Problem?
Group of answer choices

It reduces the number of vertices

It simplifies the matrix by subtracting the smallest value in each row

It eliminates all zeros in the matrix

It calculates the total cost of the tour

A

It simplifies the matrix by subtracting the smallest value in each row

19
Q

Which of the following is a weakness of brute-force algorithms?
Group of answer choices

Limited applicability

Complexity in implementation

Some brute-force algorithms are unacceptably slow

Lack of systematic approach

A

Some brute-force algorithms are unacceptably slow

20
Q

What is the main idea behind the Divide and Conquer algorithm?
Group of answer choices

Dividing a problem into smaller sub-problems, solving them independently, and combining their solutions

Solving problems using brute force

Using dynamic programming to solve problems

Solving problems iteratively without recursion

A

Dividing a problem into smaller sub-problems, solving them independently, and combining their solutions

21
Q

Which sorting algorithm uses the Divide and Conquer approach?
Group of answer choices

Bubble Sort

Merge Sort

Selection Sort

Insertion Sort

22
Q

In Merge Sort, what is the first step?
Group of answer choices

Divide the array into equal halves until atomic values are achieved

Combine the sorted halves

Swap elements in the array

Compare elements from both halves

A

Divide the array into equal halves until atomic values are achieved

23
Q

What is the time complexity of Merge Sort in the worst case?
Group of answer choices

O(n log n)

O(n^2)

O(log n)

O(n)

24
Which algorithm is highly efficient but has a worst-case time complexity of O(n^2)? Group of answer choices Strassen's Matrix Multiplication Quick Sort Merge Sort Binary Search
Quick Sort
25
What is the role of the pivot in Quick Sort? Group of answer choices To divide the array into three equal parts To sort the array directly To find the median of the array To partition the array into two parts: one with smaller values and one with larger values
To partition the array into two parts: one with smaller values and one with larger values
26
What is the time complexity of Quick Sort in the best and average cases? Group of answer choices O(n^2) O(log n) O(n) O(n log n)
O(n log n)
27
Binary Search works on which type of data collection? Group of answer choices Unsorted arrays Graphs Linked lists Sorted arrays
Sorted arrays
28
What is the time complexity of Binary Search? Group of answer choices O(log n) O(n log n) O(n) O(n^2)
O(log n)
29
In Binary Search, how is the middle element determined? Group of answer choices mid = (low + high) / 2 mid = low + (high - low) / 2 mid = low + high mid = (high - low) / 2
mid = low + (high - low) / 2
30
Which algorithm is used for matrix multiplication and reduces the number of recursive calls? Group of answer choices Strassen’s Matrix Multiplication Naive Matrix Multiplication Floyd-Warshall Algorithm Dijkstra’s Algorithm
Strassen’s Matrix Multiplication
31
What is the time complexity of Strassen’s Matrix Multiplication? Group of answer choices O(n log n) O(n^2.8074) O(n^2) O(n^3)
O(n^2.8074)
32
How many recursive calls does Strassen’s algorithm use for matrix multiplication? Group of answer choices 5 8 6 7
7
33
What problem does the Closest Pair algorithm solve? Group of answer choices Multiplying matrices Finding the pair of points with the smallest distance between them Sorting an array Finding the shortest path in a graph
Finding the pair of points with the smallest distance between them
34
What is the time complexity of the Closest Pair algorithm in the optimized case? Group of answer choices O(n log log n) O(n) O(n log n) O(n^2)
O(n log n)
35
In the Closest Pair algorithm, why is the strip array created? Group of answer choices To consider points within a certain distance from the dividing line To store all points in sorted order To calculate the median of the points To divide the points into two halves
To consider points within a certain distance from the dividing line
36
Which step in the Divide and Conquer approach involves solving smaller sub-problems independently? Group of answer choices Conquer/Solve Divide/Break Partition Merge/Combine
Conquer/Solve
37
Which of the following is NOT an application of the Divide and Conquer algorithm? Group of answer choices Binary Search Merge Sort Breadth-First Search Quick Sort
Breadth-First Search
38
What is the space complexity of Quick Sort? Group of answer choices O(n log n) O(n^2) O(n) O(log n)
O(n log n)
39
Why is the naive matrix multiplication algorithm still preferred for small matrices? Group of answer choices It is easier to implement It has lower time complexity It requires fewer recursive calls The constants used in Strassen’s method are high, making it less efficient for small matrices
The constants used in Strassen’s method are high, making it less efficient for small matrices