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

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Java Pila/coda polimorfa. La Pila in Java - 1 package strutture; public abstract class Stack { protected int size; protected int defaultGrowthSize=5;
For(int i = 1; i
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
static void Main() { int i = 0; if (i == 0) { int a = 5; int b = 15; if (a == 5) { int c = 3; int d = 99; }
Winter 2006CISC121 - Prof. McLeod1 Stuff Assn 5 is available and due Friday, 7pm. Winding down! Possible Remaining topics: –Shell and Radix sorts (not.
Sort the given string, without using string handling functions.
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Session 3 Algorithm. Algorithm Algorithm is a set of steps that are performed to solve a problem. The example below describes an algorithm Example Check.
Passing information through Parameters ( our setter methods or mutators) Formal Parameter – parameter in the method. public void SetA(int x){ (int x) is.
Selection Sorting Lecture 21. Selection Sort Given an array of length n, –In first iteration: Search elements 0 through n-1 and select the smallest Swap.
Analysis of Recursive Algorithms What is a recurrence relation? Forming Recurrence Relations Solving Recurrence Relations Analysis Of Recursive Factorial.
Overloading methods review When is the return statement required? What do the following method headers tell us? public static int max (int a, int b)
Analysis of Recursive Algorithms What is a recurrence relation? Forming Recurrence Relations Solving Recurrence Relations Analysis Of Recursive Factorial.
Lecture 8 Analysis of Recursive Algorithms King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer.
Java: How to Program Arrays and ArrayLists Summary Yingcai Xiao.
Analysis of Recursive Algorithms What is a recurrence relation? Forming Recurrence Relations Solving Recurrence Relations Analysis Of Recursive Factorial.
P247. Figure 9-1 p248 Figure 9-2 p251 p251 Figure 9-3 p253.
Public static void main( String [] args ){ getBinaryNumberFromUser(); //asks the user to type a binary number while( notDone() ){ int binary_digit = getNextDigit();
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Part 2. Searching Arrays Looking for a specific element in an array E.g., whether a certain score (85) is in a list of scores Linear search Binary search.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Lecture #9: Sorting Algorithms خوارزميات الترتيب Dr. Hmood Al-Dossari King Saud University Department of Computer Science 22 April 2012.
Public class Edo1 { private static double euler(double y, double h, double t, Derivada d) { return y + h * d.f(y, t); } public static void euler(double.
Sorting Algorithms: Selection, Insertion and Bubble.
Output Programs These slides will present a variety of small programs. Each program has some type of array that was introduced in this chapter. Our concern.
1 Insertion sort [ ] i=1 j=1 i=2 j=2 insert i=3 at j=1 [ ] i=3 j=1 insert i=4 at j=0 [
M180: Data Structures & Algorithms in Java Sorting Algorithms Arab Open University 1.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 14 Searching and Sorting.
1. Define an array 1 Create reference arrays of objects in Java program 2 Initialize elements of arrays 3 Pass array to methods 4 Return array to methods.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
WAP to find out the number is prime or not Import java.util.*; Class Prime { public static void main(string args[]) { int n,I,res; boolean flag=true;
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
Array Sort. Sort Pass 1 Sort Pass 2 Sort Pass 3.
CSII Final Review. How many bits are in a byte? 8.
Unit 6 Analysis of Recursive Algorithms
Analysis of Recursive Algorithms
COP 3503 FALL 2012 Shayan Javed Lecture 16
using System; namespace Demo01 { class Program
CS150 Introduction to Computer Science 1
Sorting Algorithms: Selection, Insertion and Bubble
Decision statements. - They can use logic to arrive at desired results
Computing Adjusted Quiz Total Score
Mr. Dave Clausen La Cañada High School
TO COMPLETE THE FOLLOWING:
LRobot Game.
Selection sort Given an array of length n,
AP Java Warm-up Boolean Array.
Assignment 7 User Defined Classes Part 2
Java Lesson 36 Mr. Kalmes.
Arrays of Objects // The following does NOT create memory for
Recursive GCD Demo public class Euclid {
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Java Programming with Multiple Classes
Example. Sort {5, 1, 12, -5, 16, 2, 12, 14} using selection sort. Complexity analysis.
Algorithms Lakshmish Ramaswamy.
writeSpaces(10); | V +--->--->--->--->--->---+
PowerPoint Presentation Authors of Exposure Java
PowerPoint Presentation Authors of Exposure Java
Analysis of Recursive Algorithms
Introduction to Sorting Algorithms
Array Review Selection Sort
Analysis of Recursive Algorithms
Instructor: Mainak Chaudhuri
Presentation transcript:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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