För algoritm, se figur 6.9 i Java Gently, sidan 179.
-
date post
21-Dec-2015 -
Category
Documents
-
view
224 -
download
2
Transcript of För algoritm, se figur 6.9 i Java Gently, sidan 179.
![Page 1: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/1.jpg)
För algoritm, se figur 6.9i Java Gently, sidan 179
![Page 2: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/2.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
leftmost
chosen
j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 3: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/3.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
0chosen
j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 4: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/4.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
0chosen
1j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 5: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/5.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
0chosen
1j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 6: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/6.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
0chosen
1j
a
SANT
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 7: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/7.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
1j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 8: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/8.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
2j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 9: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/9.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
2j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 10: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/10.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
2j
a
Falskt
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 11: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/11.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
3j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 12: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/12.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
3j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 13: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/13.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
1chosen
3j
a
Sant
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 14: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/14.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
3j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 15: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/15.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
4j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 16: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/16.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
4j
a
temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 17: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/17.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
5j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 18: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/18.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
5j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 19: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/19.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
5j
a
temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 20: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/20.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 21: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/21.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 22: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/22.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 23: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/23.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 24: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/24.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 25: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/25.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
temp
FalsktFalskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 26: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/26.jpg)
4
0
3
1
8
2
2
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 27: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/27.jpg)
4
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 28: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/28.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
0leftmost
3chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 29: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/29.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
3chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 30: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/30.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 31: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/31.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
2j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 32: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/32.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
2j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 33: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/33.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
2j
a
2temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 34: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/34.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
3j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 35: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/35.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
3j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 36: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/36.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
3j
a
2temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 37: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/37.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
4j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 38: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/38.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
4j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 39: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/39.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
4j
a
2temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 40: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/40.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 41: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/41.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 42: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/42.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
1chosen
5j
a
2temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 43: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/43.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 44: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/44.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 45: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/45.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 46: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/46.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
6j
a
2temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 47: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/47.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 48: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/48.jpg)
2
0
3
1
8
2
4
3
9
4
2
5
4
6
5
7
1leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 49: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/49.jpg)
2
0
3
1
8
2
4
3
9
4
3
5
4
6
5
7
1leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 50: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/50.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
1leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 51: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/51.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 52: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/52.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
2chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 53: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/53.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
2chosen
3j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 54: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/54.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
2chosen
3j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 55: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/55.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
2chosen
3j
a
2temp
SANT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 56: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/56.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
3j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 57: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/57.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
4j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 58: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/58.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
4j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 59: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/59.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
4j
a
2temp
FALSKT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 60: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/60.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 61: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/61.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 62: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/62.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
3chosen
5j
a
2temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 63: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/63.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
5j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 64: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/64.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 65: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/65.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
6j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 66: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/66.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
6j
a
2temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 67: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/67.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
7j
a
2temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 68: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/68.jpg)
2
0
2
1
8
2
4
3
9
4
3
5
4
6
5
7
2leftmost
5chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 69: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/69.jpg)
2
0
2
1
8
2
4
3
9
4
8
5
4
6
5
7
2leftmost
5chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 70: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/70.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
2leftmost
5chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 71: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/71.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
5chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 72: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/72.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 73: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/73.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
4j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 74: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/74.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
4j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 75: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/75.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
4j
a
3temp
FALSKT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 76: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/76.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
5j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 77: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/77.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
5j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 78: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/78.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
5j
a
3temp
FALSKT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 79: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/79.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
6j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 80: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/80.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
6j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 81: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/81.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
6j
a
3temp
FALSKT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 82: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/82.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 83: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/83.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
3temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 84: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/84.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
3temp
FALSKT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 85: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/85.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 86: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/86.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 87: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/87.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
3leftmost
3chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 88: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/88.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
3chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 89: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/89.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
4chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 90: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/90.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
4chosen
5j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 91: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/91.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
4chosen
5j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 92: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/92.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
4chosen
5j
a
4temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 93: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/93.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
5chosen
5j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 94: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/94.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
5chosen
6j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 95: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/95.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
5chosen
6j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 96: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/96.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
5chosen
6j
a
4temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 97: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/97.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
6chosen
6j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 98: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/98.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 99: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/99.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 100: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/100.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
6chosen
7j
a
4temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 101: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/101.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
4
6
5
7
4leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 102: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/102.jpg)
2
0
2
1
3
2
4
3
9
4
8
5
9
6
5
7
4leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 103: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/103.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
4leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 104: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/104.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
6chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 105: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/105.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 106: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/106.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
6j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 107: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/107.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
6j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 108: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/108.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
6j
a
4temp
Falskt
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 109: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/109.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 110: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/110.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
4temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 111: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/111.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
4temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 112: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/112.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
4temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 113: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/113.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
5
7
5leftmost
5chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 114: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/114.jpg)
2
0
2
1
3
2
4
3
4
4
8
5
9
6
8
7
5leftmost
5chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 115: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/115.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
5leftmost
5chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 116: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/116.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
5chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 117: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/117.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
6chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 118: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/118.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
6chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 119: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/119.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
6chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 120: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/120.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
6chosen
7j
a
5temp
Sant
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 121: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/121.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
7chosen
7j
a
5temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 122: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/122.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
8
7
6leftmost
7chosen
7j
a
8temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 123: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/123.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
9
6
9
7
6leftmost
7chosen
7j
a
8temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 124: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/124.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
8
6
9
7
6leftmost
7chosen
7j
a
8temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 125: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/125.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
8
6
9
7
6leftmost
7chosen
7j
a
8temp
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}
![Page 126: För algoritm, se figur 6.9 i Java Gently, sidan 179.](https://reader030.fdocuments.net/reader030/viewer/2022032522/56649d6a5503460f94a49593/html5/thumbnails/126.jpg)
2
0
2
1
3
2
4
3
4
4
5
5
8
6
9
7
leftmost
chosen
j
a
temp
FÄRDIGSORTERAT
Static void selectionSort(int[] a, int n){ int temp; int chosen; for(int leftmost = 0: leftmost < n-1. Leftmost++) { chosen = leftmost; for(int j = leftmost + 1; j < n; j++) if(a[j] < a[chosen]) chosen = j; temp = a[chosen]; a[chosen] = a[leftmost]; a[leftmost] = temp; }}