 # 2 Execution Traces on a List Using Selection Sort and Bubble Sort

## Question

1). Sort the list E, X, A, M, P, L, E in alphabetical order by selection sort. Trace the execution steps also besides providing the pseudo code.

2). Sort the list E, X, A, M, P, L, E in alphabetical order by bubble sort. Trace the execution steps also besides providing the pseudo code.

Note: include the actual list elements in the execution of the algorithms.

## 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.

We can consider our array to sort by Selection Sort being A[0..6] where A=E, A=X,…A=E.
The above pseudocode can be equivalently rewritten as:
For i=0 to 7-2=5 do Min=i
For j=i+1 to 7-1=6 do
If A(j) < A(min) min=j
Swap A(i) with A(min)

Step1)
i=0=> min=0
for j=1 to 6 do if A(j)< A(min) min=j
swap A(0) with A(min)
j=1=> if A(1) <A(0) => X <E nothing
j=2=> if A(2) <A(0)=> A<E => min=2
j=3=> if A(3)<A(2)=> M < A nothing
j=4=> if A(4) < A(2)=> P < A nothing
j=5=> if A(5) < A(2) => L < A nothing
j=6=> If A(6) <A(2)=> E < A nothing
swap (A(0), A(2))= > swap (E, A)=A, E => the array is A X E M P L E

Step2)...
\$13.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Data Structures and Algorithms Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

• 1
• 2
• 3
Live Chats