LAB REPORT-4
Course Code : ICE 207
Course Title : Data Structure
Name of Problem : Implement SORT ARRAY using SELECTION SORT
Student’s Name : Md. Rafsan Mahmud
Student’s ID : 2019-1-50-023
Section : 01
Submitted To : Dr. Anup Kumar Paul (Assistan Professor, ECE Depertment)
Submission Date :
Source :
import [Link];
public class main {
public static void main(String[] args) {
final int SIZE=7;
int[] data =new int[SIZE];
Scanner input = new Scanner([Link]);
[Link]("Insert " +SIZE+ " data : ");
for(int i=0;i<SIZE;i++) {
data[i]=[Link]();
}
selection_sort ob= new selection_sort(data);
[Link]();
}}
public class selection_sort {
int[] data;
public selection_sort(int[] data) {
[Link] = data;
}
public void printArray() {
[Link]();
for(int i=0;i<[Link];i++) {
[Link](data[i]+" ");
}
}
public void selectionsort() {
for(int i=0;i<[Link];i++) {
int minindex=i;
[Link]("\nMinIndex = " +minindex);
for( int j=i+1;j<[Link];j++) {
if(data[j]<data[minindex]) {
minindex=j;
}
}
int temp=data[minindex];
data[minindex]=data[i];
data[i]=temp;
printArray();
}}}
Output :