Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Array{
- public static void insertsort(int []list){
- for(int i=1;i<list.length;i++){
- int temp=list[i];
- for(int j=i;j>0;j--){
- if(list[j-1]>temp){
- list[j]=list[j-1];
- }
- else{
- list[j]=temp;
- break;
- }
- }
- }
- }
- public static void selectionsort(int []list){
- for(int i=0;i<list.length-1;i++){
- int min=list[i];
- int index=i;
- for(int j=i;j<list.length;j++){
- if(list[j]<min){
- min=list[j];
- index=j;
- }
- }
- list[index]=list[i];
- list[i]=min;
- }
- }
- public static void burblesort(int []list){
- for(int i=0;i<list.length;i++){
- for(int j=0;j<list.length-1;j++){
- if(list[j]>list[j+1]){
- int temp=list[j];
- list[j]=list[j+1];
- list[j+1]=temp;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment