Presentation is loading. Please wait.

Presentation is loading. Please wait.

För algoritm, se figur 6.9 i Java Gently, sidan 179.

Similar presentations


Presentation on theme: "För algoritm, se figur 6.9 i Java Gently, sidan 179."— Presentation transcript:

1 För algoritm, se figur 6.9 i Java Gently, sidan 179

2 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; }

3 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 0 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; }

4 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 0 chosen 1 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; }

5 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 0 chosen 1 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; }

6 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 0 chosen 1 j 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; }

7 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 1 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; }

8 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 2 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; }

9 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 2 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; }

10 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 2 j 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; }

11 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 3 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; }

12 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 3 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; }

13 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 1 chosen 3 j 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; }

14 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 3 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; }

15 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 4 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; }

16 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 4 j 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; }

17 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 5 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; }

18 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 5 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; }

19 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 5 j 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; }

20 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 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; }

21 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 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; }

22 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 j 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; }

23 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 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; }

24 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 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; }

25 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 j 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; }

26 4 0 3 1 8 2 2 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 j a 2 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; }

27 4 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 j a 2 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; }

28 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 0 leftmost 3 chosen 6 j a 2 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; }

29 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 3 chosen 6 j a 2 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; }

30 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 6 j a 2 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; }

31 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 2 j a 2 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; }

32 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 2 j a 2 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; }

33 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 2 j a 2 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; }

34 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 3 j a 2 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; }

35 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 3 j a 2 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; }

36 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 3 j a 2 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; }

37 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 4 j a 2 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; }

38 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 4 j a 2 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; }

39 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 4 j a 2 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; }

40 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 5 j a 2 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; }

41 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 5 j a 2 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; }

42 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 1 chosen 5 j a 2 temp 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; }

43 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 5 j a 2 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; }

44 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 6 j a 2 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; }

45 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 6 j a 2 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; }

46 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 6 j a 2 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; }

47 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 7 j a 2 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; }

48 2 0 3 1 8 2 4 3 9 4 2 5 4 6 5 7 1 leftmost 5 chosen 7 j a 2 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; }

49 2 0 3 1 8 2 4 3 9 4 3 5 4 6 5 7 1 leftmost 5 chosen 7 j a 2 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; }

50 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 1 leftmost 5 chosen 7 j a 2 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; }

51 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 7 j a 2 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; }

52 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 2 chosen 7 j a 2 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; }

53 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 2 chosen 3 j a 2 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; }

54 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 2 chosen 3 j a 2 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; }

55 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 2 chosen 3 j a 2 temp 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; }

56 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 3 j a 2 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; }

57 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 4 j a 2 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; }

58 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 4 j a 2 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; }

59 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 4 j a 2 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; }

60 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 5 j a 2 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; }

61 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 5 j a 2 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; }

62 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 3 chosen 5 j a 2 temp 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; }

63 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 5 j a 2 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; }

64 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 6 j a 2 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; }

65 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 6 j a 2 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; }

66 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 6 j a 2 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; }

67 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 7 j a 2 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; }

68 2 0 2 1 8 2 4 3 9 4 3 5 4 6 5 7 2 leftmost 5 chosen 7 j a 3 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; }

69 2 0 2 1 8 2 4 3 9 4 8 5 4 6 5 7 2 leftmost 5 chosen 7 j a 3 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; }

70 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 2 leftmost 5 chosen 7 j a 3 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; }

71 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 5 chosen 7 j a 3 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; }

72 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 3 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; }

73 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 4 j a 3 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; }

74 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 4 j a 3 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; }

75 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 4 j a 3 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; }

76 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 5 j a 3 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; }

77 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 5 j a 3 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; }

78 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 5 j a 3 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; }

79 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 6 j a 3 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; }

80 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 6 j a 3 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; }

81 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 6 j a 3 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; }

82 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 3 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; }

83 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 3 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; }

84 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 3 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; }

85 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 4 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; }

86 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 4 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; }

87 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 3 leftmost 3 chosen 7 j a 4 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; }

88 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 3 chosen 7 j a 4 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; }

89 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 4 chosen 7 j a 4 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; }

90 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 4 chosen 5 j a 4 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; }

91 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 4 chosen 5 j a 4 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; }

92 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 4 chosen 5 j a 4 temp 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; }

93 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 5 chosen 5 j a 4 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; }

94 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 5 chosen 6 j a 4 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; }

95 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 5 chosen 6 j a 4 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; }

96 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 5 chosen 6 j a 4 temp 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; }

97 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 6 chosen 6 j a 4 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; }

98 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

99 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

100 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

101 2 0 2 1 3 2 4 3 9 4 8 5 4 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

102 2 0 2 1 3 2 4 3 9 4 8 5 9 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

103 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 4 leftmost 6 chosen 7 j a 4 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; }

104 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 6 chosen 7 j a 4 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; }

105 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 4 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; }

106 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 6 j a 4 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; }

107 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 6 j a 4 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; }

108 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 6 j a 4 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; }

109 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 4 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; }

110 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 4 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; }

111 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 4 temp 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; }

112 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 4 temp 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; }

113 2 0 2 1 3 2 4 3 4 4 8 5 9 6 5 7 5 leftmost 5 chosen 7 j a 5 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; }

114 2 0 2 1 3 2 4 3 4 4 8 5 9 6 8 7 5 leftmost 5 chosen 7 j a 5 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; }

115 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 5 leftmost 5 chosen 7 j a 5 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; }

116 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 5 chosen 7 j a 5 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; }

117 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 6 chosen 7 j a 5 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; }

118 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 6 chosen 7 j a 5 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; }

119 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 6 chosen 7 j a 5 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; }

120 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 6 chosen 7 j a 5 temp 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; }

121 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 7 chosen 7 j a 5 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; }

122 2 0 2 1 3 2 4 3 4 4 5 5 9 6 8 7 6 leftmost 7 chosen 7 j a 8 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; }

123 2 0 2 1 3 2 4 3 4 4 5 5 9 6 9 7 6 leftmost 7 chosen 7 j a 8 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; }

124 2 0 2 1 3 2 4 3 4 4 5 5 8 6 9 7 6 leftmost 7 chosen 7 j a 8 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; }

125 2 0 2 1 3 2 4 3 4 4 5 5 8 6 9 7 6 leftmost 7 chosen 7 j a 8 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; }

126 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; }


Download ppt "För algoritm, se figur 6.9 i Java Gently, sidan 179."

Similar presentations


Ads by Google