CS401A's Finals: Design & Analysis of Algrthms. Module 05 Flashcards

For final exams. (27 cards)

1
Q

Definition of || What is the

  • It is a general algorithm design technique that solves a problem by dividing it into several smaller subproblems of the same type, solving each of them recursively, and then combining their solutions to get a solution to the original problem.
A

Divide and Conquer Algorithm || Design Technique?

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

Definition of || What is the

  • The figure below illustrates an example of a \_\_\_\_\_\_ \_\_\_ \_\_\_\_\_\_\_ \_\_\_\_\_\_\_\_\_ in a typical case:
(A problem of size n)
v > (Subproblm 1 of size n/2)
    v > [solution subproblm 1]
v > (Subprblm 2 size n/2)   v
    v > [soln subprblm 2] > v
                            v
[solution to original problem]
A

Divide and Conquer Algorithm || Design Technique?

Divide and Conquer algorithm

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

Definition of Divide and Conquer Algorithm

Importance of Divide and Conquer Algorithm Design Technique

A
  • Solving difficult problems
  • Algorithm efficiency
  • Parallelism
  • Memory Access
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Application of

is a type of sorting algorithm that repeatedly divides the data in half, sorts each half separately, and combines the sorted halves into one sorted array.

A

Divide and Conquer Algorithm Design Technique

Merge Sort

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

Application of

Example:
Initial Hand:

 0 1 2 3 4  5 6 
[2|Q|J|7|A|10|5]

1st Split:

A

Divide and Conquer Algorithm Design Technique

Merge Sort

1st Split:

 0 1 2 3   4  5 6 
[2|Q|J|7] [A|10|5]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Application of

Example:
Initial Hand:

 0 1 2 3 4  5 6 
[2|Q|J|7|A|10|5]

2nd Split:

A

Divide and Conquer Algorithm Design Technique

Merge Sort

2nd Split:

 0 1   2 3   4  5 6 
[2|Q] [J|7] [A|10|5]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Application of

Example:
Initial Hand:

 0 1 2 3 4  5 6 
[2|Q|J|7|A|10|5]

3rd Split:

A

Divide and Conquer Algorithm Design Technique

Merge Sort

3rt Split:

 0 1   2 3   4  5   6 
[2|Q] [J|7] [A|10] [5]

 0   1   2   3   4    5   6 
[2] [Q] [J] [7] [A] [10] [5]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Application of

Example:
Initial Hand:
3rd Split:

 0   1   2   3   4    5   6 
[2] [Q] [J] [7] [A] [10] [5]

1st to 3rd Merge:

A

Divide and Conquer Algorithm Design Technique

Merge Sort

1st to 3rd Merge:

[2] [Q] [J] [7] [10|A] [5]

[2|7|J|Q] [5|10|A]

[2|5|7|10|J|Q|A]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Application of

is a type of sorting algorithm in which the main idea is to partition the array into two (2) regions: small items are moved to the left side of the array and large items are moved to the right side. After partitioning, the sort is repeated on the left and right sides.

A

Divide and Conquer Algorithm Design Technique

Quick Sort

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

Application of

is a type of search algorithm that is used to locate an element in an ordered array. It is advisable to use it whenever the list starts to become larger.

A

Divide and Conquer Algorithm Design Technique

Binary search

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

Application of

The steps of the Binary search starts by

testing the target.

If the target is equal to the middle item,

quit.

Otherwise:

A

Divide and Conquer Algorithm Design Technique

The steps of the \_\_\_\_\_\_ \_\_\_\_\_\_ starts by

If the target is equal to the middle item,

Otherwise:
1. Divide the array into two sub-arrays about half as large. If the target is smaller than the middle item, choose the left sub-array. If the target is larger than the middle item, choose the right sub-array.
2. Divide (Solve) the sub-array by determining whether the target is in that sub-array. Unless the sub-array is sufficiently small, use recursion to do this.
3. Obtain the solution to the array from the solution to the sub-array.

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

Application of

The steps of the Binary search starts by testing the target. If the target is equal to the middle item, quit. Otherwise:
1. Divide the array into two sub-arrays about half as large. If the target is smaller than the middle item,

If the target is larger than the middle item,

A

Divide and Conquer Algorithm Design Technique

  1. Divide the array into two sub-arrays about half as large. If the target is \_\_\_\_\_\_\_ \_\_\_\_ \_\_\_ \_\_\_\_\_\_ \_\_\_\_,

choose the left sub-array.

If the target is \_\_\_\_\_\_ \_\_\_\_ \_\_\_ \_\_\_\_\_\_ \_\_\_\_,

choose the right sub-array.

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

Application of

The steps of the Binary search starts by testing the target. If the target is equal to the middle item, quit. Otherwise:
2. Divide (Solve) the sub-array by determining whether the target is in that sub-array. Unless the sub-array is sufficiently small,

A

Divide and Conquer Algorithm Design Technique

use recursion to do this.

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

Application of

The steps of the Binary search starts by testing the target. If the target is equal to the middle item, quit. Otherwise:
3. Obtain the solution to the array from the

A

Divide and Conquer Algorithm Design Technique

solution to the sub-array.

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

Application of

is a type of tree data structure in which no node can have more than two (2) subtrees. In other words, a node can have zero, one, or two subtrees. These subtrees are designated as the left subtree and right subtree.

A

Divide and Conquer Algorithm Design Technique

Binary Tree

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

Application of

requires that each node of the tree be processes once and only once in a predetermined sequence.

A

Divide and Conquer Algorithm Design Technique

Binary tree traversal

17
Q

Application of

The \_\_\_ (_) general approaches to the traversal sequence are as follows:

A

Divide and Conquer Algorithm Design Technique

two (2)
* Depth-first traversal
* Breadth-first traversal

18
Q

Application of

The
general approaches to the traversal sequence are as follows:

is where the processing proceeds along a path from the root through one child to the most distant descendent of the first child before processing a second child.

A

Divide and Conquer Algorithm Design Technique

  • Depth-first traversal
19
Q

Application of

The
general approaches to the traversal sequence are as follows:

In other words, in the \_\_\_\_\_\_\_\_\_\_\_ search \_\_\_\_\_\_\_\_\_, all of the descendants of a child are processed before going on to the next child.

A

Divide and Conquer Algorithm Design Technique

depth-first search traversal

20
Q

Application of

\_\_\_\_\_ (_) types of depth-first search binary tree traversal

A

Divide and Conquer Algorithm Design Technique

Three (3)
preorder traversal
inorder traversal
postorder traversal

21
Q

Application of

types of depth-first search binary tree traversal

the root is visited first and successively moving to the left subtree until a leaf is reached, visiting each node on the way there.

A

Divide and Conquer Algorithm Design Technique

In the preorder traversal,

22
Q

Application of

types of depth-first search binary tree traversal

Once there are no more children on the left of a node, the children on the right subtree are visited.

A

Divide and Conquer Algorithm Design Technique

In the preorder traversal,

23
Q

Application of

types of depth-first search binary tree traversal

the left node is visited first, and subsequently visits the parent of that node.

A

Divide and Conquer Algorithm Design Technique

In the inorder traversal,

24
Q

Application of

types of depth-first search binary tree traversal

It then goes to the child on the right and finds the leftmost node in the tree to visit.

A

Divide and Conquer Algorithm Design Technique

In the inorder traversal,

25
# **Application of** types of depth-first search binary tree traversal the leftmost leaf in the tree is visisted first, then going up to the parent and down the second leftmost leaf in the same branch, and so on until the parent is the last node to be visited within a branch.
**Divide and Conquer Algorithm Design Technique** In the ***postorder traversal***,
26
# **Application of** The general approaches to the traversal sequence are as follows: is where the processing proceeds horizontally from the root to all of its children, then to its children's children, and so forth until all nodes have been processed.
**Divide and Conquer Algorithm Design Technique** * *Breadth-first traversal*
27
# **Application of** The general approaches to the traversal sequence are as follows: In other words, in the `_____________ _________`, each level is completely processed before the next level is started.
**Divide and Conquer Algorithm Design Technique** breadth-first traversal