Module 3 Flashcards

Brute Force Boi

1
Q

A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved

A

Brute Force

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

Examples of Brute Force

A
  1. Computing an (a > 0, n a nonnegative integer)
  2. Computing n!
  3. Multiplying two matrices
  4. Searching for a key of a given value in a list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Brute Force Strengths

A
  • wide applicability
  • simplicity
  • yields reasonable algorithms for some important problems (e.g., matrix multiplication, sorting, searching, string matching)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Brute Force Weaknesses

A
  • rarely yields efficient algorithms
  • some brute-force algorithms are unacceptably slow
  • not as constructive as some other design techniques
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

__________ sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.

A

Selection Sort Algorithm

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

T or F

The Selection Sort Algorithm maintains two subarrays in a given array.

A

True

1) The subarray which is already sorted.
2) Remaining subarray which is unsorted.

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

T or F

In every iteration of selection sort, the minimum element (considering descending order) from the unsorted subarray is picked and moved to the sorted subarray.

A

False (Descending)

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

In Brute Force String Matching what is a string of m characters to search for?

A

Pattern

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

In Brute Force String Matching what is a a (longer) string of n characters to search in?

A

Text

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

Compares a given pattern with all substrings
of a given text.

A

Brute Force String Matching

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

T or F

Those comparisons between substring and pattern proceed character by
character unless a mismatch is found.

A

True

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

Whenever a mismatch is found, the remaining character comparisons for that substring are dropped and the next substring can be selected
immediately.

A

True

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

Brute Force Algorithm Steps:

A

Step 1 Align pattern at beginning of text

Step 2 Moving from left to right, compare each character of pattern to the corresponding character in text until all characters are found to match (successful search); or a mismatch is detected

Step 3 While pattern is not found and the text is not yet exhausted, realign pattern one position to the right and repeat Step 2

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

A brute force solution to a problem involving search for an element with a special property, usually among combinatorial objects such as permutations, combinations, or subsets of a set.

A

Exhaustive Search

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

Exhaustive Search Method

A
  • generate a list of all potential solutions to the problem in a systematic manner evaluate potential solutions one by one, disqualifying infeasible ones and, for an optimization problem, keeping track of the best one found so far
  • when search ends, announce the solution(s) found
How well did you know this?
1
Not at all
2
3
4
5
Perfectly