0% found this document useful (0 votes)
7 views1 page

Selection Sort Dry Run Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Selection Sort Dry Run Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Dry RUN for selection Sort

10, 2, 6, 3
2, 10, 6, 3
[Link] = 4

for (int i=0;i<[Link]-1;i++) i=0 to i<3


{
int m=i; // m=0;
for(int j=i+1;j<A. length; j++) // j=1,2,3 when i=0
{
if(A[j]<A[m]) (2<10) (6<2) (3<2)
m=j; m=1,
} //
int temp=A[i]; // 10
A[i]=A[m]; A[0]=A[m] = A[1]=2
A[m]=temp; A[1]=10
}

Dry RUN for selection Sort

10, 2, 6, 3
2, 10, 6, 3
2, 3, 6, 10
[Link] = 4

for (int i=0;i<[Link]-1;i++) i=1


{
int m=i; // m=1;
for(int j=i+1;j<A. length; j++) j=2,3
{
if(A[j]<A[m]) (6<10) (3<6)
m=j; m=3
} // A[3]=3
int temp=A[i]; // 10
A[i]=A[m]; A[1]=A[m] = A[3]=3
A[m]=temp; A[3]=10
}

You might also like