0% found this document useful (0 votes)
5 views3 pages

Lab 4

This lab report outlines the implementation of a selection sort algorithm in Java for sorting an array of integers. The report includes the course details, student information, and the source code for the program. The program prompts the user to input data, sorts it using selection sort, and prints the sorted array.

Uploaded by

johnwick150023
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Lab 4

This lab report outlines the implementation of a selection sort algorithm in Java for sorting an array of integers. The report includes the course details, student information, and the source code for the program. The program prompts the user to input data, sorts it using selection sort, and prints the sorted array.

Uploaded by

johnwick150023
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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 :

You might also like