Selection Sort Code in Java | DSA

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

For More Queries WhatsApp or Call on : +919008963671

Udemy Courses:

Рекомендации по теме
Комментарии
Автор

Thank you so much for This level of Teaching us

jyothijyothi
Автор

yeah. Please keep uploading more videos on DSA

Aditya-oixw
Автор

Nice Explanation Sir

Another logic
package Sorting;

import java.util.Arrays;

public class SelectionSort2 {

public static void main(String[] args) {
int[] arr = {6, 9, 1, 2, 3, 0, 12, 4};
//int[] arr = {6, 5, 2, 8, 9, 4};
int size = arr.length;
int maxIndex = -1;
Sorting : " +Arrays.toString(arr));

int k=size;
for(int i=0;i<k-1;i++) {
= i;
j=i+1;j<k;j++) {
< arr[j])
= j;





{
= arr[maxIndex] ^ arr[k-1];
= arr[maxIndex] ^ arr[k-1];
= arr[maxIndex] ^ arr[k-1];




: " +Arrays.toString(arr));
}

System.out.println(" After Sorting : " +Arrays.toString(arr));

}

}

syam
Автор

thank you sir. Could you make a video on explaining the design patterents and where they should be use
in real world applications

naveenalla
Автор

Swapping max with last position code

private static int[] selectionSort(int[] arr) {
int placeholder = 0;
int max = 0;
for(int i=arr.length-1;i>=0;i--){
max = i;
for(int temp=0;temp<i;temp++){
if(arr[temp]>arr[i])
max = temp;
}
placeholder = arr[i];
arr[i] = arr[max];
arr[max] = placeholder;
}
return arr;
}

znwecwu
Автор

Haha 10th ICSE board students here 😂 like mee

martanddwivedi-pqqb
Автор

ow so basically it's a gold digger algorithm hahhahaa

akosisydney