 # Step-by-step Execution for Selection Sort & Bubble Sort

Subject Computer Science Data Structures and Algorithms

## Question

1)Sort the list E, X, A, M, P, L, E in alphabetical order by selection sort.

Using this as an example:

//Sorts a given array by selection sort
//Input: An array A[0..n − 1] of orderable elements
//Output: Array A[0..n − 1] sorted in non-decreasing order
for i ←0 to n − 2 do
min←i
for j ←i + 1 to n − 1 do
if A[j ]<A[min] min←j
swap A[i] and A[min]

2) Sort the list E, X, A, M, P, L, E in alphabetical order by bubble sort.

Using this as an example:

//Sorts a given array by bubble sort
//Input: An array A[0..n − 1] of orderable elements
//Output: Array A[0..n − 1] sorted in non-decreasing order
for i ←0 to n − 2 do
for j ←0 to n − 2 − i do
if A[j + 1]<A[j ] swap A[j ] and A[j + 1]

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

Note: as methodology we can consider A being 1, B being 2 and so on (in order to have in mind an easier example of how Selection Sort works)
At step “i” the minimum element (increasing order) is swapped with the i-th entry from the array
EXAMPLE    step 1 – search for the smallest in the range 1st to 7th
swap the 3rd with the 1st...

This is only a preview of the solution. Please use the purchase button to see the entire solution

## Related Homework Solutions \$100.00
Stack
Queue
Unsorted
List
Analysis
Comparison
Data
Structures
Computer
Science
Matrix Chain Multiplication Using Dynamic Programming Algorithm \$18.00
Matrix
Chain
Multiplication
Dynamic
Programming
Algorithm
Optimal
Product
Dimension
Matrix-chain-order
Technique
Randomization & Probability Questions \$18.00
Randomized
Probability
Algorithm
Dice
Conditional
False
Positive
Negative
Sum
Result
Sample
Graph Theory: Gale-Shapely Algorithm Implementation \$45.00
Computer Science
Programming
Java
Gale-Shapely Algorithm
Graph Theory
Mathematics
Complete Bi-Partite Graphs
Vertices
Edges
Statements
Variables
Loops
Input Values
Output Values
The Longest Increasing Subsequence Problem \$40.00
Programming
Computer Science
Longest Increasing Subsequence
Variables
Running Time
Algorithms
Complexity
Loops
Arrays
Computer Science - Algorithm Assignment \$25.00
Algorithm
Computer Science
Dynamic Programming
Longest Increasing Subsequence
Array
Live Chats