# create a algorithm for selection sort, show as pseudocode or flowchart

Page 1 of 1

## 1 Replies - 5963 Views - Last Post: 23 April 2012 - 08:22 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=276509&amp;s=c51c7a4098351e816ceb8ee342cfd48e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 leany17

Reputation: 0
• Posts: 1
• Joined: 23-April 12

# create a algorithm for selection sort, show as pseudocode or flowchart

Posted 23 April 2012 - 07:43 PM

hi, I am a mature age student learning java and need to use (23, 19, 35, 12, 30) as the values to create an algorithm for the selection sort, show it as pseudocode OR a flowchart, and desk check.
The bubble sort data we are need to change to selection sort is;
algorithm bubbleSort
Pre item is an array of values
n is the number of values in the array
Post itme has been sorted from losest to highest values
```for k=0 to n -2
for j=0 to n -k -2
if item [j]>item[j+1]
temp =item[j]
item[j] =item[j=1]
item[j] =temp
end if
end for
end for
end bubbleSort

I have tried reading different sources and am wondering if I am on the right track.. and how do I desk check?

Selectsort (int item[],int n) {
int min,tmp,k,j,min_id;

for (k=0; k<n-1; k++) {
min = item[j];
for (j=k+1; j<n; j++)
if (item[j] < min) {
min = item[j];
min_id = j;
}
tmp = item[k];
item[k] = item[min_id];
item[min_id] = tmp;
}
}

```

thanks

Is This A Good Question/Topic? 0

## Replies To: create a algorithm for selection sort, show as pseudocode or flowchart

### #2 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

## Re: create a algorithm for selection sort, show as pseudocode or flowchart

Posted 23 April 2012 - 08:22 PM

What you have is a bubble sort exactly as in that post

http://www.dreaminco...ost__p__1598082

and the following