189 views
2 2 votes

Which algorithm-design strategies can reasonably describe Bubble Sort?

  1. Greedy
     
  2. Brute force
     
  3. Decrease-and-conquer
     
  4. Divide-and-conquer
     
  5. Dynamic programming

2 Answers

1 1 vote

B. Brute force

Bubble Sort repeatedly scans through the unsorted elements and directly compares adjacent pairs.

It does not use a sophisticated method to avoid unnecessary comparisons.

Therefore, it is primarily classified as a brute-force algorithm.


C. Decrease-and-conquer

After the first pass, the largest element reaches its final position.

Therefore, the remaining unsorted problem has size: $n-1$

After the next pass, it becomes: $n-2$ and so on.

Thus, Bubble Sort can also be viewed as reducing the unsorted problem by one element after every pass.

This corresponds to the decrease-and-conquer idea.

It does not divide the problem into independent subproblems, so Divide-and-Conquer is incorrect. 

It also does not use overlapping subproblems or an optimal-choice rule, so Dynamic Programming and Greedy are incorrect. 

The source classifies Bubble Sort as brute force and also reasonably as decrease-and-conquer.


Answer: B and C

0 0 votes

A. Greedy - NOT CORRECT:
Make locally optimal choice towards an optimal objective. But bubble sort simply runs through the unsorted portion of the array, swapping adjacent elements if needed. So we are definitely not choosing the greedy action here. So not greedy.

B. Brute Force - CORRECT:
We are going through the unsorted portion of the array in each iteration the same way regardless of whether the elements in it are already sorted or not. So we go through every possibility even if not needed. So definitely Brute Force.

C. Decrease and Conquer - CORRECT:
After each iteration we decrease the size of the unsorted portion by 1. That is Decrease and Conquer.

D. Divide and Conquer - NOT CORRECT:
Divide and conquer divides a problem into two or more sub-problems, solves them independently and combines the result. So this is not Divide and Conquer.

E. Dynamic Programming - NOT CORRECT:
When we have overlapping subproblems with optimal sub-structure, we resuse solutions using dynamic programming, We do not have that here.

Answer: B, C

Answer:
Position:
Show:

Related questions

2 2 votes
2 2 answers
147
147 views
GO Classes asked Aug 12
147 views
After the first complete pass of Bubble Sort on an array of size $n$, which element is guaranteed to be in its correct position?The smallest element The largest element A...
3 3 votes
2 2 answers
223
223 views
GO Classes asked Aug 12
223 views
You are given an initial array:$[22,10,14,37,14,4,3]$For the following array, indicate which sorting algorithm could produce this state after an iteration has completed:$...
3 3 votes
2 2 answers
162
162 views
GO Classes asked Aug 12
162 views
What effect does the initial ordering of the records have on the number of comparisons performed by standard Selection Sort?No effect Only a constant-factor difference Th...
2 2 votes
2 2 answers
183
183 views
GO Classes asked Aug 12
183 views
Suppose Binary Search is used in Insertion Sort to locate where the $i$th element should be inserted among the first $i-1$ elements.What is the worst-case running time of...